index.vue 5.4 KB

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