user.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. <template>
  2. <!--pages/user/user.wxml-->
  3. <view class="container">
  4. <!-- 用户信息 -->
  5. <!-- # indef MP-wei -->
  6. <!-- <view class="userinfo">
  7. <view class="userinfo-avatar">
  8. <open-data type="userAvatarUrl"></open-data>
  9. </view>
  10. <view class="userinfo-name">
  11. <open-data type="userNickName"></open-data>
  12. </view>
  13. </view>
  14. <view class="binding-phone">
  15. <text class="show-tip">绑定手机号后可查看订单和领取优惠券,</text>
  16. <text class="gotobinding" @tap="toBindingPhone">去绑定</text>
  17. </view> -->
  18. <view class="userinfo" v-if="isAuthInfo">
  19. <view class="userinfo-con">
  20. <view class="userinfo-avatar">
  21. <!-- <open-data type="userAvatarUrl"></open-data> -->
  22. <image :src="loginResult.pic ? (loginResult.pic.indexOf('http') === -1 ? picDomain + loginResult.pic : loginResult.pic) : '../../static/images/icon/head04.png'"></image>
  23. </view>
  24. <view class="userinfo-name">
  25. <view>{{loginResult.nickName ? loginResult.nickName : "用户昵称"}}</view>
  26. <!-- <open-data type="userNickName"></open-data> -->
  27. </view>
  28. </view>
  29. </view>
  30. <view class="userinfo-none" v-if="!isAuthInfo">
  31. <view class="default-pic" @tap="toLogin">
  32. <image src="../../static/images/icon/head04.png"></image>
  33. </view>
  34. <view class="none-login" @tap="toLogin">
  35. <button class="unlogin">未登录</button>
  36. <button class="click-login">点击登录账号</button>
  37. </view>
  38. </view>
  39. <!-- end 用户信息 -->
  40. <view class="list-cont">
  41. <!-- 订单状态 -->
  42. <view class="total-order">
  43. <view class="order-tit">
  44. <text style="font-weight:bold">我的订单</text>
  45. <view class="checkmore" @tap="toOrderListPage" data-sts="0">
  46. <text>查看全部 </text>
  47. <text class="arrowhead"></text>
  48. </view>
  49. </view>
  50. <view class="procedure">
  51. <view class="items" @tap="toOrderListPage" data-sts="1">
  52. <image src="/static/images/icon/toPay.png"></image>
  53. <text>待支付</text>
  54. <text class="num-badge" v-if="orderAmount.unPay>0">{{orderAmount.unPay}}</text>
  55. </view>
  56. <view class="items" @tap="toOrderListPage" data-sts="2">
  57. <image src="/static/images/icon/toDelivery.png"></image>
  58. <text>待发货</text>
  59. <text class="num-badge" v-if="orderAmount.payed>0">{{orderAmount.payed}}</text>
  60. </view>
  61. <view class="items" @tap="toOrderListPage" data-sts="3">
  62. <image src="/static/images/icon/toTake.png"></image>
  63. <text>待收货</text>
  64. <text class="num-badge" v-if="orderAmount.consignment>0">{{orderAmount.consignment}}</text>
  65. </view>
  66. <view class="items" @tap="toOrderListPage" data-sts="5">
  67. <image src="/static/images/icon/toComment.png"></image>
  68. <text>已完成</text>
  69. </view>
  70. </view>
  71. </view>
  72. <!--end 订单状态 -->
  73. <view class="prod-col">
  74. <view class="col-item" @tap="myCollectionHandle">
  75. <view v-if="loginResult" class="num">{{collectionCount}}</view>
  76. <view v-else class="num">--</view>
  77. <view class="tit">我的收藏</view>
  78. </view>
  79. <view class="col-item" @tap="handleTips">
  80. <view v-if="loginResult" class="num">5</view>
  81. <view v-else class="num">--</view>
  82. <view class="tit">我的消息</view>
  83. </view>
  84. <view class="col-item" @tap="handleTips">
  85. <view v-if="loginResult" class="num">3</view>
  86. <view v-else class="num">--</view>
  87. <view class="tit">我的足迹</view>
  88. </view>
  89. </view>
  90. <view class="my-menu">
  91. <view class="memu-item" @tap="toDistCenter">
  92. <view class="i-name">
  93. <image src="/static/images/icon/promotion.png"></image>
  94. <text>分销中心</text>
  95. </view>
  96. <view class="arrowhead"></view>
  97. </view>
  98. <view class="memu-item" @tap="toCouponCenter">
  99. <view class="i-name">
  100. <image src="/static/images/icon/getCoupon.png"></image>
  101. <text>领券中心</text>
  102. </view>
  103. <view class="arrowhead"></view>
  104. </view>
  105. <view class="memu-item" @tap="toMyCouponPage">
  106. <view class="i-name">
  107. <image src="/static/images/icon/myCoupon.png"></image>
  108. <text>我的优惠券</text>
  109. </view>
  110. <view class="arrowhead"></view>
  111. </view>
  112. <view class="memu-item" @tap="toAddressList">
  113. <view class="i-name">
  114. <image src="/static/images/icon/myAddr.png"></image>
  115. <text>收货地址</text>
  116. </view>
  117. <view class="arrowhead"></view>
  118. </view>
  119. </view>
  120. <!--end 列表项 -->
  121. <view class="log-out" @tap="logout" v-if="isAuthInfo">
  122. <view class="log-out-n">
  123. <text>退出登录</text>
  124. </view>
  125. </view>
  126. </view>
  127. </view>
  128. </template>
  129. <script>
  130. // pages/user/user.js
  131. var http = require("../../utils/http.js");
  132. var util = require("../../utils/util.js");
  133. var config = require("../../utils/config.js");
  134. export default {
  135. data() {
  136. return {
  137. orderAmount: '',
  138. sts: '',
  139. collectionCount: 0,
  140. isAuthInfo: false,
  141. loginResult: '',
  142. picDomain: config.picDomain
  143. };
  144. },
  145. components: {},
  146. props: {},
  147. /**
  148. * 生命周期函数--监听页面加载
  149. */
  150. onLoad: function(options) {},
  151. /**
  152. * 生命周期函数--监听页面初次渲染完成
  153. */
  154. onReady: function() {},
  155. /**
  156. * 生命周期函数--监听页面显示
  157. */
  158. onShow: function() {
  159. //加载订单数字
  160. var ths = this; // var status = ths.data.status
  161. ths.setData({
  162. loginResult: uni.getStorageSync("loginResult"),
  163. // isAuthInfo: Boolean(wx.getStorageSync('loginResult').userId),
  164. });
  165. if (ths.loginResult) {
  166. ths.setData({
  167. isAuthInfo: true
  168. })
  169. } else {
  170. ths.setData({
  171. isAuthInfo: false
  172. })
  173. }
  174. if (ths.isAuthInfo) {
  175. uni.showLoading();
  176. var params = {
  177. url: "/p/myOrder/orderCount",
  178. method: "GET",
  179. data: {},
  180. callBack: function(res) {
  181. uni.hideLoading();
  182. ths.setData({
  183. orderAmount: res
  184. });
  185. }
  186. };
  187. http.request(params);
  188. this.showCollectionCount();
  189. }
  190. },
  191. /**
  192. * 生命周期函数--监听页面隐藏
  193. */
  194. onHide: function() {},
  195. /**
  196. * 生命周期函数--监听页面卸载
  197. */
  198. onUnload: function() {},
  199. /**
  200. * 页面相关事件处理函数--监听用户下拉动作
  201. */
  202. onPullDownRefresh: function() {},
  203. /**
  204. * 页面上拉触底事件的处理函数
  205. */
  206. onReachBottom: function() {},
  207. /**
  208. * 用户点击右上角分享
  209. */
  210. onShareAppMessage: function() {},
  211. methods: {
  212. toDistCenter: function() {
  213. uni.showToast({
  214. icon: "none",
  215. title: '该功能未开源'
  216. });
  217. },
  218. toCouponCenter: function() {
  219. uni.showToast({
  220. icon: "none",
  221. title: '该功能未开源'
  222. });
  223. },
  224. toMyCouponPage: function() {
  225. uni.showToast({
  226. icon: "none",
  227. title: '该功能未开源'
  228. });
  229. },
  230. handleTips: function() {
  231. uni.showToast({
  232. icon: "none",
  233. title: '该功能未开源'
  234. });
  235. },
  236. toAddressList: function() {
  237. uni.navigateTo({
  238. url: '/pages/delivery-address/delivery-address'
  239. });
  240. },
  241. // 跳转绑定手机号
  242. toBindingPhone: function() {
  243. uni.navigateTo({
  244. url: '/pages/binding-phone/binding-phone'
  245. });
  246. },
  247. toOrderListPage: function(e) {
  248. var sts = e.currentTarget.dataset.sts;
  249. uni.navigateTo({
  250. url: '/pages/orderList/orderList?sts=' + sts
  251. });
  252. },
  253. /**
  254. * 查询所有的收藏量
  255. */
  256. showCollectionCount: function() {
  257. var ths = this;
  258. uni.showLoading();
  259. var params = {
  260. url: "/p/user/collection/count",
  261. method: "GET",
  262. data: {},
  263. callBack: function(res) {
  264. uni.hideLoading();
  265. ths.setData({
  266. collectionCount: res
  267. });
  268. }
  269. };
  270. http.request(params);
  271. },
  272. /**
  273. * 我的收藏跳转
  274. */
  275. myCollectionHandle: function() {
  276. var url = '/pages/prod-classify/prod-classify?sts=5';
  277. var id = 0;
  278. var title = "我的收藏商品";
  279. if (id) {
  280. url += "&tagid=" + id + "&title=" + title;
  281. }
  282. uni.navigateTo({
  283. url: url
  284. });
  285. },
  286. /**
  287. * 去登陆
  288. */
  289. toLogin: function() {
  290. uni.navigateTo({
  291. url: "../accountLogin/accountLogin"
  292. })
  293. },
  294. /**
  295. * 退出登录
  296. */
  297. logout: function() {
  298. // 请求退出登陆接口
  299. http.request({
  300. url: '/logOut',
  301. method: 'post',
  302. callBack: res => {
  303. util.removeTabBadge()
  304. uni.removeStorageSync('loginResult');
  305. uni.removeStorageSync('token');
  306. // this.$Router.pushTab('/pages/index/index')
  307. uni.showToast({
  308. title: "退出成功",
  309. icon: "none"
  310. })
  311. this.setData({
  312. orderAmount: ''
  313. });
  314. setTimeout(() => {
  315. uni.switchTab({
  316. url: "/pages/index/index"
  317. })
  318. }, 1000)
  319. }
  320. })
  321. },
  322. }
  323. };
  324. </script>
  325. <style>
  326. @import "./user.css";
  327. </style>