index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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="https://cdn.uviewui.com/uview/common/logo.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. request({
  87. url: "/appMessage/getMessageCategory",
  88. method: "post",
  89. data: {
  90. acceptUserId:this.$store.state.storeInfo.storeId,
  91. userId:this.$store.state.storeInfo.userId,
  92. },
  93. })
  94. .then((res) => {
  95. console.log(res);
  96. this.orderList = res.data.category;
  97. console.log(this.orderList.length)
  98. for (let i = 0; i < res.data.data.category.length; i++) {
  99. // this.orderList = res.data.data.category[i]
  100. this.gatTime = res.data.data.category[i].gatTime;
  101. }
  102. })
  103. .catch((err) => {
  104. console.log(err);
  105. })
  106. .finally(() => {
  107. setTimeout(() => {
  108. uni.hideLoading();
  109. this.loading = false;
  110. }, 300);
  111. });
  112. },
  113. inSystem(index) {
  114. console.log(index);
  115. // console.log(index)
  116. // this.$u.route({
  117. // url: 'pages/msg/System-message/index',
  118. // })
  119. },
  120. click(index) {
  121. console.log(index);
  122. // this.orderList.splice(index, 1);
  123. request({
  124. url: "/appMessage/deleteMessage",
  125. method: "post",
  126. data: {
  127. acceptUserId:this.$store.state.storeInfo.storeId,
  128. sendUserId: index,
  129. userId:this.$store.state.storeInfo.userId,
  130. },
  131. })
  132. .then((res) => {
  133. this.$u.toast(`删除了第${index}个cell`);
  134. this.getDate();
  135. })
  136. .catch((err) => {
  137. console.log(err);
  138. })
  139. .finally(() => {
  140. setTimeout(() => {
  141. uni.hideLoading();
  142. this.loading = false;
  143. }, 300);
  144. });
  145. },
  146. // 如果打开一个的时候,不需要关闭其他,则无需实现本方法
  147. open(index) {
  148. console.log(index);
  149. // console.log(this.orderList[index].show)
  150. // 先将正在被操作的swipeAction标记为打开状态,否则由于props的特性限制,
  151. // 原本为'false',再次设置为'false'会无效
  152. // this.orderList[index].show = true;
  153. console.log(this.orderList[index].show);
  154. // this.orderList.map((val, idx) => {
  155. // console.log(index)
  156. // console.log(idx)
  157. // if (index != idx) this.orderList[index].show = false;
  158. this.orderList[index].show = true;
  159. this.orderList.map((val, idx) => {
  160. if (index != idx) this.orderList[idx].show = false;
  161. });
  162. // })
  163. },
  164. },
  165. };
  166. </script>
  167. <style lang="scss" scoped>
  168. .u-page {
  169. margin-bottom: 100rpx;
  170. }
  171. .item {
  172. display: flex;
  173. padding: 20rpx;
  174. }
  175. image {
  176. width: 120rpx;
  177. flex: 0 0 120rpx;
  178. height: 120rpx;
  179. margin-right: 20rpx;
  180. border-radius: 12rpx;
  181. }
  182. .title {
  183. text-align: left;
  184. font-size: 34rpx;
  185. color: #333333;
  186. font-weight: bold;
  187. margin-top: 20rpx;
  188. }
  189. .title-wrap {
  190. width: 280rpx;
  191. margin-left: 30rpx;
  192. }
  193. .title-wrap-one {
  194. margin-top: 10rpx;
  195. font-size: 23rpx;
  196. color: #999999;
  197. }
  198. .title-wrap-two {
  199. margin-left: 130rpx;
  200. margin-top: 20rpx;
  201. }
  202. .title-wrap-two > view:nth-child(1) {
  203. font-size: 19rpx;
  204. color: #999999;
  205. }
  206. .title-wrap-two-one {
  207. width: 35rpx;
  208. height: 35rpx;
  209. background: #fc3228;
  210. border-radius: 50%;
  211. color: #fff;
  212. text-align: center;
  213. font-size: 19rpx;
  214. margin: 0 auto;
  215. margin-top: 15rpx;
  216. }
  217. </style>