index.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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. // this.addDate()
  63. },
  64. filters: {
  65. formatDate: function (time) {
  66. var now = new Date();
  67. var year = now.getFullYear();
  68. var month = now.getMonth() + 1;
  69. var day = now.getDate();
  70. if (month < 10) {
  71. month = "0" + month;
  72. }
  73. if (day < 10) {
  74. day = "0" + day;
  75. }
  76. let nowDay = year + "-" + month + "-" + day;
  77. if (nowDay != time.substring(0, 10)) {
  78. return time.substring(0, 10);
  79. } else {
  80. return time.substring(11, 19);
  81. }
  82. },
  83. },
  84. methods: {
  85. getDate() {
  86. uni.showLoading({
  87. title: '加载中...'
  88. });
  89. request({
  90. url: "/appMessage/getMessageCategory",
  91. method: "post",
  92. data: {
  93. acceptUserId:this.$store.state.storeInfo.storeId,
  94. userId:this.$store.state.storeInfo.userId,
  95. },
  96. })
  97. .then((res) => {
  98. console.log(res);
  99. this.orderList = res.data.category;
  100. console.log(this.orderList.length)
  101. for (let i = 0; i < this.orderList.length; i++) {
  102. // this.orderList = res.data.data.category[i]
  103. this.gatTime = this.orderList[i].gatTime;
  104. }
  105. })
  106. .catch((err) => {
  107. console.log(err);
  108. })
  109. .finally(() => {
  110. setTimeout(() => {
  111. uni.hideLoading();
  112. this.loading = false;
  113. }, 300);
  114. });
  115. },
  116. inSystem(index) {
  117. console.log(index);
  118. },
  119. click(index) {
  120. console.log(index);
  121. // this.orderList.splice(index, 1);
  122. request({
  123. url: "/appMessage/deleteMessage",
  124. method: "post",
  125. data: {
  126. acceptUserId:this.$store.state.storeInfo.storeId,
  127. sendUserId: index,
  128. userId:this.$store.state.storeInfo.userId,
  129. },
  130. })
  131. .then((res) => {
  132. this.$u.toast(`删除成功`);
  133. this.getDate();
  134. })
  135. .catch((err) => {
  136. console.log(err);
  137. })
  138. .finally(() => {
  139. setTimeout(() => {
  140. uni.hideLoading();
  141. this.loading = false;
  142. }, 300);
  143. });
  144. },
  145. // 如果打开一个的时候,不需要关闭其他,则无需实现本方法
  146. open(index) {
  147. console.log(index);
  148. console.log(this.orderList[index].show);
  149. this.orderList[index].show = true;
  150. this.orderList.map((val, idx) => {
  151. if (index != idx) this.orderList[idx].show = false;
  152. });
  153. // })
  154. },
  155. },
  156. };
  157. </script>
  158. <style lang="scss" scoped>
  159. .u-page {
  160. margin-bottom: 100rpx;
  161. }
  162. .item {
  163. display: flex;
  164. padding: 20rpx;
  165. }
  166. image {
  167. width: 120rpx;
  168. flex: 0 0 120rpx;
  169. height: 120rpx;
  170. margin-right: 20rpx;
  171. border-radius: 12rpx;
  172. }
  173. .title {
  174. text-align: left;
  175. font-size: 34rpx;
  176. color: #333333;
  177. font-weight: bold;
  178. margin-top: 20rpx;
  179. }
  180. .title-wrap {
  181. width: 280rpx;
  182. margin-left: 30rpx;
  183. }
  184. .title-wrap-one {
  185. margin-top: 10rpx;
  186. font-size: 23rpx;
  187. color: #999999;
  188. }
  189. .title-wrap-two {
  190. margin-left: 130rpx;
  191. margin-top: 20rpx;
  192. }
  193. .title-wrap-two > view:nth-child(1) {
  194. font-size: 19rpx;
  195. color: #999999;
  196. }
  197. .title-wrap-two-one {
  198. width: 35rpx;
  199. height: 35rpx;
  200. background: #fc3228;
  201. border-radius: 50%;
  202. color: #fff;
  203. text-align: center;
  204. font-size: 19rpx;
  205. margin: 0 auto;
  206. margin-top: 15rpx;
  207. }
  208. </style>