index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <template>
  2. <view>
  3. <view class="u-page">
  4. <u-swipe-action :show="item.show" :index="index" v-for="(item, index) in orderList" @click="click(item.sendUserId)"
  5. @content-click="inSystem" @open="open(index)" :options="options">
  6. <navigator :url="'./System-message/index?sendUserId='+item.sendUserId"
  7. class="item u-border-bottom">
  8. <image mode="aspectFill" src="https://cdn.uviewui.com/uview/common/logo.png" />
  9. <!-- 此层wrap在此为必写的,否则可能会出现标题定位错误 -->
  10. <view class="title-wrap">
  11. <text class="title u-line-2">{{ item.msgTitle }}</text>
  12. <view class="title-wrap-one">
  13. 【{{ item.sendUserName }} 】
  14. </view>
  15. </view>
  16. <view class="title-wrap-two">
  17. <view>
  18. {{ item.gatTime|formatDate}}
  19. <!-- 12.25 -->
  20. </view>
  21. <view v-if="item.unread===0">
  22. </view>
  23. <view v-else>
  24. <view class="title-wrap-two-one">
  25. {{ item.unread }}
  26. </view>
  27. </view>
  28. </view>
  29. </navigator>
  30. </u-swipe-action>
  31. </view>
  32. <!-- <u-tabbar v-model="current" :list="list"></u-tabbar> -->
  33. </view>
  34. </template>
  35. <script>
  36. import {
  37. request
  38. } 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. text: '删除',
  50. style: {
  51. backgroundColor: '#dd524d'
  52. }
  53. }],
  54. };
  55. },
  56. created() {
  57. },
  58. onShow() {
  59. this.getDate()
  60. // this.addDate()
  61. },
  62. filters: {
  63. formatDate: function(time) {
  64. var now = new Date()
  65. var year = now.getFullYear();
  66. var month = now.getMonth() + 1;
  67. var day = now.getDate();
  68. if (month < 10) {
  69. month = "0" + month;
  70. }
  71. if (day < 10) {
  72. day = "0" + day;
  73. }
  74. let nowDay = year + "-" + month + "-" + day
  75. if (nowDay != time.substring(0, 10)) {
  76. return time.substring(0, 10)
  77. } else {
  78. return time.substring(11, 19)
  79. }
  80. },
  81. },
  82. methods: {
  83. getDate() {
  84. request({
  85. url: '/appMessage/getMessageCategory',
  86. method: 'post',
  87. data: {
  88. "acceptUserId": '3000',
  89. 'userId': ''
  90. }
  91. }).then(res => {
  92. console.log(res)
  93. this.orderList = res.data.category
  94. for (let i = 0; i < res.data.data.category.length; i++) {
  95. // this.orderList = res.data.data.category[i]
  96. this.gatTime = res.data.data.category[i].gatTime
  97. }
  98. }).catch(err => {
  99. console.log(err)
  100. })
  101. .finally(() => {
  102. setTimeout(() => {
  103. uni.hideLoading();
  104. this.loading = false;
  105. }, 300)
  106. })
  107. },
  108. inSystem(index) {
  109. console.log(index)
  110. // console.log(index)
  111. // this.$u.route({
  112. // url: 'pages/msg/System-message/index',
  113. // })
  114. },
  115. click(index) {
  116. console.log(index)
  117. // this.orderList.splice(index, 1);
  118. request({
  119. url: '/appMessage/deleteMessage',
  120. method: 'post',
  121. data: {
  122. "acceptUserId": '3000',
  123. "sendUserId": index,
  124. 'userId': ''
  125. }
  126. }).then(res => {
  127. this.$u.toast(`删除了第${index}个cell`);
  128. this.getDate()
  129. }).catch(err => {
  130. console.log(err)
  131. })
  132. .finally(() => {
  133. setTimeout(() => {
  134. uni.hideLoading();
  135. this.loading = false;
  136. }, 300)
  137. })
  138. },
  139. // 如果打开一个的时候,不需要关闭其他,则无需实现本方法
  140. open(index) {
  141. console.log(index)
  142. // console.log(this.orderList[index].show)
  143. // 先将正在被操作的swipeAction标记为打开状态,否则由于props的特性限制,
  144. // 原本为'false',再次设置为'false'会无效
  145. // this.orderList[index].show = true;
  146. console.log(this.orderList[index].show)
  147. // this.orderList.map((val, idx) => {
  148. // console.log(index)
  149. // console.log(idx)
  150. // if (index != idx) this.orderList[index].show = false;
  151. this.orderList[index].show = true;
  152. this.orderList.map((val, idx) => {
  153. if(index != idx) this.orderList[idx].show = false;
  154. })
  155. // })
  156. }
  157. },
  158. };
  159. </script>
  160. <style lang="scss" scoped>
  161. .u-page {
  162. margin-bottom: 100rpx;
  163. }
  164. .item {
  165. display: flex;
  166. padding: 20rpx;
  167. }
  168. image {
  169. width: 120rpx;
  170. flex: 0 0 120rpx;
  171. height: 120rpx;
  172. margin-right: 20rpx;
  173. border-radius: 12rpx;
  174. }
  175. .title {
  176. text-align: left;
  177. font-size: 29rpx;
  178. color: #333333;
  179. font-weight: bold;
  180. margin-top: 20rpx;
  181. }
  182. .title-wrap {
  183. width: 280rpx;
  184. }
  185. .title-wrap-one {
  186. margin-top: 10rpx;
  187. font-size: 23rpx;
  188. color: #999999;
  189. }
  190. .title-wrap-two {
  191. margin-left: 150rpx;
  192. margin-top: 10rpx;
  193. }
  194. .title-wrap-two>view:nth-child(1) {
  195. font-size: 19rpx;
  196. color: #999999;
  197. }
  198. .title-wrap-two-one {
  199. width: 35rpx;
  200. height: 35rpx;
  201. background: #FC3228;
  202. border-radius: 50%;
  203. color: #fff;
  204. text-align: center;
  205. font-size: 19rpx;
  206. margin: 0 auto;
  207. margin-top: 15rpx;
  208. }
  209. </style>