index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <template>
  2. <view>
  3. <view class="u-page" v-if="orderList.length!=0">
  4. <u-swipe-action :show="item.show" :index="index" v-for="(item, index) in orderList" :key="index" @click="click(item.sendUserId)"
  5. @content-click="inSystem" @open="open(index)" :options="options">
  6. <navigator
  7. :url="'./System-message/index?sendUserId=' + item.sendUserId"
  8. class="item u-border-bottom"
  9. >
  10. <image
  11. mode="aspectFill"
  12. src="../../static/sailun/xiaoxi.png"
  13. />
  14. <!-- 此层wrap在此为必写的,否则可能会出现标题定位错误 -->
  15. <view class="title-wrap">
  16. <text class="title u-line-2">{{ item.msgTitle }}</text>
  17. <view class="title-wrap-one"> 【{{ item.sendUserName }} 】 </view>
  18. </view>
  19. <view class="title-wrap-two">
  20. <view>
  21. {{ item.gatTime | formatDate }}
  22. <!-- 12.25 -->
  23. </view>
  24. <view v-if="item.unread === 0"> </view>
  25. <view v-else>
  26. <view class="title-wrap-two-one">
  27. {{ item.unread }}
  28. </view>
  29. </view>
  30. </view>
  31. </navigator>
  32. </u-swipe-action>
  33. </view>
  34. <u-empty style="margin-top: 100rpx;" v-else text="暂无数据" mode="list"></u-empty>
  35. <!-- <u-tabbar v-model="current" :list="list"></u-tabbar> -->
  36. </view>
  37. </template>
  38. <script>
  39. import { request } from "../../common/request/request";
  40. require("promise.prototype.finally").shim();
  41. export default {
  42. data() {
  43. return {
  44. currentdate: "",
  45. orderList: [],
  46. disabled: false,
  47. btnWidth: 180,
  48. show: false,
  49. options: [
  50. {
  51. text: "删除",
  52. style: {
  53. backgroundColor: "#dd524d",
  54. },
  55. },
  56. ],
  57. };
  58. },
  59. created() {},
  60. onShow() {
  61. this.getDate();
  62. },
  63. filters: {
  64. formatDate: function (time) {
  65. var now = new Date();
  66. var year = now.getFullYear();
  67. var month = now.getMonth() + 1;
  68. var day = now.getDate();
  69. if (month < 10) {
  70. month = "0" + month;
  71. }
  72. if (day < 10) {
  73. day = "0" + day;
  74. }
  75. let nowDay = year + "-" + month + "-" + day;
  76. if (nowDay != time.substring(0, 10)) {
  77. return time.substring(0, 10);
  78. } else {
  79. return time.substring(11, 19);
  80. }
  81. },
  82. },
  83. methods: {
  84. getDate() {
  85. uni.showLoading({
  86. title: '加载中...'
  87. });
  88. request({
  89. url: "/appMessage/getMessageCategory",
  90. method: "post",
  91. data: {
  92. acceptUserId:this.$store.state.storeInfo.storeId,
  93. userId:this.$store.state.storeInfo.userId,
  94. },
  95. })
  96. .then((res) => {
  97. this.orderList = res.data.category;
  98. for (let i = 0; i < this.orderList.length; i++) {
  99. this.gatTime = this.orderList[i].gatTime;
  100. }
  101. })
  102. .catch((err) => {
  103. })
  104. .finally(() => {
  105. setTimeout(() => {
  106. uni.hideLoading();
  107. this.loading = false;
  108. }, 300);
  109. });
  110. },
  111. inSystem(index) {
  112. },
  113. click(index) {
  114. request({
  115. url: "/appMessage/deleteMessage",
  116. method: "post",
  117. data: {
  118. acceptUserId:this.$store.state.storeInfo.storeId,
  119. sendUserId: index,
  120. userId:this.$store.state.storeInfo.userId,
  121. },
  122. })
  123. .then((res) => {
  124. this.$u.toast(`删除成功`);
  125. this.getDate();
  126. })
  127. .catch((err) => {
  128. })
  129. .finally(() => {
  130. setTimeout(() => {
  131. uni.hideLoading();
  132. this.loading = false;
  133. }, 300);
  134. });
  135. },
  136. // 如果打开一个的时候,不需要关闭其他,则无需实现本方法
  137. open(index) {
  138. this.orderList[index].show = true;
  139. this.orderList.map((val, idx) => {
  140. if (index != idx) this.orderList[idx].show = false;
  141. });
  142. // })
  143. },
  144. },
  145. };
  146. </script>
  147. <style lang="scss" scoped>
  148. .u-page {
  149. margin-bottom: 100rpx;
  150. }
  151. .item {
  152. display: flex;
  153. padding: 20rpx;
  154. }
  155. image {
  156. width: 120rpx;
  157. flex: 0 0 120rpx;
  158. height: 120rpx;
  159. margin-right: 20rpx;
  160. border-radius: 12rpx;
  161. }
  162. .title {
  163. text-align: left;
  164. font-size: 34rpx;
  165. color: #333333;
  166. font-weight: bold;
  167. margin-top: 20rpx;
  168. }
  169. .title-wrap {
  170. width: 280rpx;
  171. margin-left: 30rpx;
  172. }
  173. .title-wrap-one {
  174. margin-top: 10rpx;
  175. font-size: 23rpx;
  176. color: #999999;
  177. }
  178. .title-wrap-two {
  179. margin-left: 130rpx;
  180. margin-top: 20rpx;
  181. }
  182. .title-wrap-two > view:nth-child(1) {
  183. font-size: 19rpx;
  184. color: #999999;
  185. }
  186. .title-wrap-two-one {
  187. width: 35rpx;
  188. height: 35rpx;
  189. background: #fc3228;
  190. border-radius: 50%;
  191. color: #fff;
  192. text-align: center;
  193. font-size: 19rpx;
  194. margin: 0 auto;
  195. margin-top: 15rpx;
  196. }
  197. </style>