user.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. <template>
  2. <view class="container">
  3. <view class="vheigh"></view>
  4. <view class="top-bg"><view class="title">会员中心</view></view>
  5. <view class="userinfo-box">
  6. <view class="userinfo-info">
  7. <view class="portrait-box"><image class="portrait" :src="userInfo.avatar || '/static/error/missing-face.png'"></image></view>
  8. <view class="username clamp">y{{ userInfo.nickname || '游客' }}</view>
  9. <view class="phone clamp">{{ userInfo.phone | phrule }}</view>
  10. <view class="level clamp">{{ userInfo.level_info ? userInfo.level_info.name : '会员' }}</view>
  11. </view>
  12. <view class="money-box flex">
  13. <view class="money-box-item" @click="navTo('/pages/money/wallet')">
  14. <view class="money-box-item-price">{{ userInfo.now_money || '0.00' }}</view>
  15. <view class="money-box-item-name">钱包余额</view>
  16. </view>
  17. <view class="xian"></view>
  18. <view class="money-box-item" @click="navTo('/pages/user/scoreAccumulate')">
  19. <view class="money-box-item-price">{{ userInfo.integral || '0.00' }}</view>
  20. <view class="money-box-item-name">兑换券余额</view>
  21. </view>
  22. <view class="xian"></view>
  23. <view class="money-box-item" @click="navTo('/pages/user/barter')">
  24. <view class="money-box-item-price">{{ userInfo.barter_integral || '0.00' }}</view>
  25. <view class="money-box-item-name">钱</view>
  26. </view>
  27. </view>
  28. <!-- <view class="userinfo-box-tip">本月分享:0人,本月您已复购:0PV</view> -->
  29. </view>
  30. <view class="main-box">
  31. <view class="main-item" @click="navTo('/pages/order/order?state=0')">
  32. <view class="image"><image class="image1" src="../../static/icon/u1.png" mode=""></image></view>
  33. <view class="main-item-font">订单管理</view>
  34. </view>
  35. <view class="main-item" @click="navTo('/pages/set/address')">
  36. <view class="image"><image class="image2" src="../../static/icon/u2.png" mode=""></image></view>
  37. <view class="main-item-font">地址管理</view>
  38. </view>
  39. <view class="main-item" @click="navTo('/pages/money/recharge?type=1')">
  40. <view class="image"><image class="image3" src="../../static/icon/u3.png" mode=""></image></view>
  41. <view class="main-item-font">电子钱包</view>
  42. </view>
  43. <view class="main-item" @click="navTo('/pages/user/award')">
  44. <view class="image"><image class="image4" src="../../static/icon/u4.png" mode=""></image></view>
  45. <view class="main-item-font">奖金管理</view>
  46. </view>
  47. <view class="main-item" @click="navTo('/pages/user/shareQrCode')">
  48. <view class="image"><image class="image6" src="../../static/icon/u6.png" mode=""></image></view>
  49. <view class="main-item-font">分享二维码</view>
  50. </view>
  51. <view class="main-item" @click="navTo('/pages/user/team')">
  52. <view class="image"><image class="image5" src="../../static/icon/u5.png" mode=""></image></view>
  53. <view class="main-item-font">分享查询</view>
  54. </view>
  55. <view class="main-item" @click="navTo('/pages/user/favorites')">
  56. <view class="image"><image class="image7" src="../../static/icon/u7.png" mode=""></image></view>
  57. <view class="main-item-font">我的收藏</view>
  58. </view>
  59. <view class="main-item" @click="navTo('/pages/set/set')">
  60. <view class="image"><image class="image8" src="../../static/icon/u8.png" mode=""></image></view>
  61. <view class="main-item-font">个人资料</view>
  62. </view>
  63. <!-- <view class="main-item" @click="navTo('/pages/user/about')">
  64. <view class="image"><image class="image9" src="../../static/icon/u9.png" mode=""></image></view>
  65. <view class="main-item-font">关于我们</view>
  66. </view> -->
  67. <view class="main-item" @click="navTo('/pages/merchant/merchant')" v-if="userInfo.store != 0">
  68. <view class="image"><image class="image10" src="../../static/icon/u10.png" mode=""></image></view>
  69. <view class="main-item-font">店铺管理</view>
  70. </view>
  71. </view>
  72. </view>
  73. </template>
  74. <script>
  75. import { mapState, mapMutations } from 'vuex';
  76. import uniList from '@/components/uni-list/uni-list.vue';
  77. import uniListItem from '@/components/uni-list-item/uni-list-item.vue';
  78. import { getAddressList, setAddressDefault, addressDel } from '@/api/user.js';
  79. import { orderData, getUserInfo } from '@/api/user.js';
  80. import { saveUrl, interceptor } from '@/utils/loginUtils.js';
  81. let startY = 0,
  82. moveY = 0,
  83. pageAtTop = true;
  84. export default {
  85. components: {
  86. uniList,
  87. uniListItem
  88. },
  89. data() {
  90. return {};
  91. },
  92. onShow() {
  93. // 判断是否已经登录
  94. if (this.hasLogin) {
  95. this.loadBaseData();
  96. }
  97. },
  98. filters: {
  99. phrule(provider) {
  100. if (provider) {
  101. var subStr1 = provider.substr(0, 3);
  102. var subStr2 = provider.substr(provider.length - 4, 4);
  103. var subStr = subStr1 + '...' + subStr2;
  104. provider = subStr;
  105. }
  106. return provider;
  107. }
  108. },
  109. onReady() {
  110. // 初始化获取页面宽度
  111. uni.createSelectorQuery()
  112. .select('.container')
  113. .fields(
  114. {
  115. size: true
  116. },
  117. data => {
  118. // 计算最多下拉的高度
  119. this.userDowm = Math.floor((data.width / 750) * 185);
  120. // 计算最大触发修改高度事件
  121. this.userMaxDowm = Math.floor((data.width / 750) * 250);
  122. }
  123. )
  124. .exec();
  125. },
  126. computed: {
  127. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
  128. },
  129. methods: {
  130. ...mapMutations('user', ['setUserInfo', 'setOrderInfo']),
  131. // 加载初始数据
  132. loadBaseData() {
  133. getUserInfo({})
  134. .then(({ data }) => {
  135. this.setUserInfo(data);
  136. // 获取用户数据完毕后在获取订单数据防止多次跳转到登录页
  137. getAddressList({
  138. page: 1,
  139. limit: 100
  140. }).then(({ data }) => {
  141. if (data.length == 0) {
  142. uni.showModal({
  143. title: '提示',
  144. content: '您未填写收货地址,请您先去填写收货地址',
  145. showCancel: false,
  146. success: function(res) {
  147. if (res.confirm) {
  148. uni.navigateTo({
  149. url: '/pages/set/address'
  150. });
  151. }
  152. }
  153. });
  154. }
  155. });
  156. })
  157. .catch(e => {
  158. console.log(e);
  159. });
  160. },
  161. /**
  162. * 统一跳转接口,拦截未登录路由
  163. * navigator标签现在默认没有转场动画,所以用view
  164. */
  165. navTo(url) {
  166. if (!this.hasLogin) {
  167. // 保存地址
  168. saveUrl();
  169. // 登录拦截
  170. interceptor();
  171. } else {
  172. uni.navigateTo({
  173. url
  174. });
  175. }
  176. }
  177. }
  178. };
  179. </script>
  180. <style lang="scss">
  181. page,
  182. .container {
  183. min-height: 100%;
  184. height: auto;
  185. background: #f8f8f8;
  186. }
  187. .vheigh {
  188. height: var(--status-bar-height);
  189. background-color: $base-color;
  190. }
  191. .top-bg {
  192. width: 750rpx;
  193. height: auto;
  194. background: #5dbc7c;
  195. padding: 20rpx 0 212rpx;
  196. .title {
  197. font-size: 34rpx;
  198. font-family: PingFang SC;
  199. font-weight: 500;
  200. color: #ffffff;
  201. text-align: center;
  202. }
  203. }
  204. .userinfo-box {
  205. width: 690rpx;
  206. background: #ffffff;
  207. border-radius: 19rpx;
  208. margin: -106rpx auto 0;
  209. .userinfo-info {
  210. position: relative;
  211. top: -70rpx;
  212. display: flex;
  213. align-items: center;
  214. flex-direction: column;
  215. line-height: 1;
  216. .portrait-box {
  217. width: 140rpx;
  218. height: 140rpx;
  219. border-radius: 50%;
  220. .portrait {
  221. width: 140rpx;
  222. height: 140rpx;
  223. border-radius: 50%;
  224. }
  225. }
  226. .username {
  227. margin-top: 24rpx;
  228. font-size: 32rpx;
  229. font-family: PingFang SC;
  230. font-weight: bold;
  231. color: #333333;
  232. }
  233. .phone {
  234. margin-top: 16rpx;
  235. font-size: 28rpx;
  236. font-family: PingFang SC;
  237. font-weight: 500;
  238. color: #666666;
  239. }
  240. .level {
  241. background: #ff4c4c;
  242. border-radius: 30rpx;
  243. padding: 10rpx 30rpx;
  244. margin-top: 10rpx;
  245. font-size: 28rpx;
  246. font-family: PingFang SC;
  247. font-weight: 500;
  248. color: #fff;
  249. }
  250. }
  251. .money-box {
  252. position: relative;
  253. top: -30rpx;
  254. .money-box-item {
  255. width: 50%;
  256. padding: 2rpx 0 8rpx;
  257. display: flex;
  258. flex-direction: column;
  259. align-items: center;
  260. line-height: 1;
  261. .money-box-item-price {
  262. font-size: 36rpx;
  263. font-family: PingFang SC;
  264. font-weight: bold;
  265. color: #333333;
  266. }
  267. .money-box-item-name {
  268. margin-top: 18rpx;
  269. font-size: 22rpx;
  270. font-family: PingFang SC;
  271. font-weight: 500;
  272. color: #666666;
  273. }
  274. }
  275. .xian {
  276. width: 1px;
  277. height: 78rpx;
  278. background: #ebebeb;
  279. }
  280. }
  281. .userinfo-box-tip {
  282. padding: 0 0 24rpx;
  283. text-align: center;
  284. font-size: 26rpx;
  285. font-family: PingFang SC;
  286. font-weight: 500;
  287. color: #ff4c4c;
  288. }
  289. }
  290. .main-box {
  291. width: 690rpx;
  292. background: #ffffff;
  293. border-radius: 19rpx;
  294. margin: 20rpx auto 0;
  295. display: flex;
  296. flex-wrap: wrap;
  297. justify-content: center;
  298. padding-bottom: 98rpx;
  299. .main-item {
  300. display: flex;
  301. flex-direction: column;
  302. align-items: center;
  303. width: 33%;
  304. padding-top: 78rpx;
  305. .image {
  306. display: flex;
  307. justify-content: center;
  308. width: 70rpx;
  309. height: 70rpx;
  310. }
  311. .image1 {
  312. width: 60rpx;
  313. height: 68rpx;
  314. }
  315. .image2 {
  316. width: 44rpx;
  317. height: 58rpx;
  318. }
  319. .image3 {
  320. width: 68rpx;
  321. height: 68rpx;
  322. }
  323. .image4 {
  324. width: 66rpx;
  325. height: 70rpx;
  326. }
  327. .image5 {
  328. width: 76rpx;
  329. height: 62rpx;
  330. }
  331. .image6 {
  332. width: 70rpx;
  333. height: 70rpx;
  334. }
  335. .image7 {
  336. width: 60rpx;
  337. height: 54rpx;
  338. }
  339. .image8 {
  340. width: 60rpx;
  341. height: 60rpx;
  342. }
  343. .image9 {
  344. width: 54rpx;
  345. height: 54rpx;
  346. }
  347. .image10 {
  348. width: 60rpx;
  349. height: 60rpx;
  350. }
  351. .main-item-font {
  352. margin-top: 24rpx;
  353. font-size: 26rpx;
  354. font-family: PingFang SC;
  355. font-weight: 500;
  356. color: #333333;
  357. line-height: 21px;
  358. }
  359. }
  360. }
  361. </style>