myMsg.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <template>
  2. <view class="my-msg">
  3. <uv-navbar title="我的消息" placeholder autoBack>
  4. <template v-slot:right>
  5. <view class="uv-nav-slot">
  6. <image
  7. class="clear-icon"
  8. :src="$handleImageUrl('/czd/clear.png')"
  9. mode=""
  10. @click.stop="messageAllRead()"
  11. ></image>
  12. </view>
  13. </template>
  14. </uv-navbar>
  15. <view class="middle">
  16. <!-- <view class="item" @click="goTodel(0, '活动消息')">
  17. <view class="left">
  18. <image
  19. :src="$handleImageUrl('/czd/myMsg_iocn1.png')"
  20. mode=""
  21. ></image>
  22. </view>
  23. <view class="right">
  24. <view class="msg">
  25. <view class="name">
  26. 活动消息
  27. <text
  28. class="count"
  29. v-if="titleOne.num == 0 ? false : titleOne.num"
  30. >{{ titleOne.num }}</text
  31. >
  32. </view>
  33. <view class="time">{{ titleOne.time ? titleOne.time : "" }}</view>
  34. </view>
  35. <view class="advertisement">{{
  36. titleOne.remark ? titleOne.remark : ""
  37. }}</view>
  38. </view>
  39. </view> -->
  40. <view class="item" @click="goTodel(1, '支付消息')">
  41. <view class="left">
  42. <!-- <text class="iconfont">&#xe641;</text> -->
  43. <image
  44. :src="$handleImageUrl('/czd/myMsg_iocn5.png')"
  45. mode=""
  46. ></image>
  47. </view>
  48. <view class="right right2">
  49. <view class="msg">
  50. <view class="name">
  51. 支付消息
  52. <text class="count" v-if="titleTwo == 0 ? false : titleTwo.num">{{
  53. titleTwo.num
  54. }}</text>
  55. </view>
  56. <view class="time">{{ titleTwo.time ? titleTwo.time : "" }}</view>
  57. </view>
  58. <view class="advertisement">{{
  59. titleTwo.remark ? titleTwo.remark : ""
  60. }}</view>
  61. </view>
  62. </view>
  63. <view class="item" @click="goTodel(2, '物流消息')">
  64. <view class="left right3">
  65. <!-- <text class="iconfont">&#xe691;</text> -->
  66. <image
  67. :src="$handleImageUrl('/czd/myMsg_iocn3.png')"
  68. mode=""
  69. ></image>
  70. </view>
  71. <view class="right right4">
  72. <view class="msg">
  73. <view class="name">
  74. 物流消息
  75. <text
  76. class="count"
  77. v-if="titleThree.num == 0 ? false : titleThree.num"
  78. >{{ titleThree.num }}</text
  79. >
  80. </view>
  81. <view class="time">{{
  82. titleThree.time ? titleThree.time : ""
  83. }}</view>
  84. </view>
  85. <view class="advertisement">{{
  86. titleThree.remark ? titleThree.remark : ""
  87. }}</view>
  88. </view>
  89. </view>
  90. <view class="item" @click="goTodel(3, '售后消息')">
  91. <view class="left">
  92. <!-- <text class="iconfont">&#xf132;</text> -->
  93. <image
  94. :src="$handleImageUrl('/czd/myMsg_iocn2.png')"
  95. mode=""
  96. ></image>
  97. </view>
  98. <view class="right right5">
  99. <view class="msg">
  100. <view class="name">
  101. 售后消息
  102. <text
  103. class="count"
  104. v-if="titleFour == 0 ? false : titleFour.num"
  105. >{{ titleFour.num }}</text
  106. >
  107. </view>
  108. <view class="time">{{ titleFour.time ? titleFour.time : "" }}</view>
  109. </view>
  110. <view class="advertisement">{{
  111. titleFour.remark ? titleFour.remark : ""
  112. }}</view>
  113. </view>
  114. </view>
  115. <!-- <view class="item" @click="goTodel(4, '系统消息')">
  116. <view class="left">
  117. <image :src="$handleImageUrl('/czd/myMsg_iocn4.png')" mode=""></image>
  118. </view>
  119. <view class="right right5">
  120. <view class="msg">
  121. <view class="name">
  122. 系统消息
  123. <text class="count" v-if="titleSix == 0 ? false : titleSix.num">{{
  124. titleSix.num
  125. }}</text>
  126. </view>
  127. <view class="time">{{ titleSix.time ? titleSix.time : "" }}</view>
  128. </view>
  129. <view class="advertisement">{{
  130. titleSix.remark ? titleSix.remark : ""
  131. }}</view>
  132. </view>
  133. </view> -->
  134. </view>
  135. </view>
  136. </template>
  137. <script setup>
  138. import { ref } from "vue";
  139. import { onShow } from "@dcloudio/uni-app";
  140. import { messageUnreadInfo_Api, messageAllRead_Api } from "@/api/userInfo.js";
  141. const msg = ref([]);
  142. // const titleOne = ref({});
  143. const titleTwo = ref({});
  144. const titleThree = ref({});
  145. const titleFour = ref({});
  146. // const titleFive = ref({});
  147. const titleSix = ref({});
  148. const goTodel = (type, name) => {
  149. uni.navigateTo({
  150. url: "/pages/user/eventDetails?type=" + type + "&name=" + name,
  151. });
  152. };
  153. const getMsg = () => {
  154. messageUnreadInfo_Api().then((res) => {
  155. if (res && res.code == 200) {
  156. // console.log(res);
  157. msg.value = res.data;
  158. res.data.forEach((v) => {
  159. if (v.type == 1) titleTwo.value = v;
  160. else if (v.type == 2) titleThree.value = v;
  161. else if (v.type == 3) titleFour.value = v;
  162. else if (v.type == 4) titleSix.value = v;
  163. });
  164. }
  165. });
  166. };
  167. const messageAllRead = () => {
  168. uni.showModal({
  169. title: "提示",
  170. content: "是否确认清除所有未读消息?",
  171. success: (res) => {
  172. if (res.confirm) {
  173. console.log("用户点击确定");
  174. uni.showLoading({
  175. title: "加载中",
  176. mask: true,
  177. });
  178. messageAllRead_Api()
  179. .then((res) => {
  180. uni.hideLoading();
  181. if (res && res.code == 200) {
  182. getMsg();
  183. }
  184. })
  185. .catch((err) => {
  186. // uni.hideLoading();
  187. });
  188. } else if (res.cancel) {
  189. console.log("用户点击取消");
  190. }
  191. },
  192. });
  193. };
  194. onShow(() => {
  195. getMsg();
  196. });
  197. </script>
  198. <style scoped lang="scss">
  199. .middle {
  200. padding: 0 30rpx;
  201. .item {
  202. display: flex;
  203. align-items: center;
  204. padding: 30rpx 0 26rpx;
  205. border-bottom: 1rpx solid #e6e6e6;
  206. .left {
  207. margin-right: 24rpx;
  208. width: 78rpx;
  209. height: 78rpx;
  210. border-radius: 50%;
  211. // background: #4bbcfe;
  212. display: flex;
  213. align-items: center;
  214. justify-content: center;
  215. color: #fff;
  216. .iconfont {
  217. font-size: 48rpx;
  218. }
  219. image {
  220. width: 78rpx;
  221. height: 78rpx;
  222. border-radius: 50%;
  223. }
  224. }
  225. .left2 {
  226. background: #ad9be5;
  227. }
  228. .left3 {
  229. background: #4ed47f;
  230. }
  231. .left4 {
  232. background: #e4c78d;
  233. }
  234. .left5 {
  235. background: #fe9168;
  236. }
  237. .right {
  238. flex: 1;
  239. display: flex;
  240. flex-direction: column;
  241. justify-content: space-around;
  242. .msg {
  243. display: flex;
  244. justify-content: space-between;
  245. align-items: flex-start;
  246. .name {
  247. font-size: 28rpx;
  248. color: #1a1a1a;
  249. font-weight: 400;
  250. text {
  251. margin-left: 10rpx;
  252. color: #ffffff;
  253. font-size: 20rpx;
  254. font-weight: 400;
  255. padding: 0 6rpx;
  256. background-color: #ff0000;
  257. border-radius: 13rpx;
  258. }
  259. }
  260. .time {
  261. font-size: 26rpx;
  262. color: #999999;
  263. font-weight: 400;
  264. }
  265. }
  266. .advertisement {
  267. font-size: 24rpx;
  268. color: #999999;
  269. font-weight: 400;
  270. margin-top: 17rpx;
  271. }
  272. }
  273. }
  274. }
  275. .count {
  276. padding: 0px 11rpx !important;
  277. border-radius: 100rpx !important;
  278. }
  279. .clear-icon {
  280. width: 40rpx;
  281. height: 40rpx;
  282. }
  283. </style>