金诚优选前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

596 lines
16 KiB

5 years ago
5 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
  1. <template>
  2. <view>
  3. <lf-nav :spreadOut="false" :showIcon="false" titleColor="white" :bgColor="nav_bg_color" title="会员中心"></lf-nav>
  4. <view class="center-top">
  5. <view class="bg-left"></view>
  6. <view class="bg-right"></view>
  7. <view class="ocupy"></view>
  8. <view class="lf-flex lf-p-32 lf-row-between">
  9. <view class="lf-row-between">
  10. <view @click="clickAvatar">
  11. <image :src="userInfo.avatar" mode="widthFix" class="center-img" v-if="userInfo.avatar"></image>
  12. <image src="/static/images/empty.png" mode="widthFix" class="center-img" v-else></image>
  13. </view>
  14. <view class="lf-row-center" @click="clickMobile">
  15. <view class="lf-color-white lf-font-36 lf-m-l-20">{{ userInfo.mobile_replace || '未登录,点此登录' }}</view>
  16. <view class="lf-iconfont icon-xiangyou lf-font-20 lf-m-l-10 lf-color-white"></view>
  17. </view>
  18. </view>
  19. <view class="lf-row-between">
  20. <button open-type="contact" style="background:none;height: 88rpx;padding: 0;margin: 0;line-height: 1.6;" class="lf-font-24 lf-m-r-30 lf-color-white lf-row-center lf-flex-column">
  21. <view class="lf-iconfont icon-kefufenxiermaikefu lf-color-white"></view>
  22. <view>
  23. 客服
  24. </view>
  25. </button>
  26. <view class="lf-row-center lf-flex-column" style="position: relative; z-index: 9;" @click="$url('/pages/user/member/code')">
  27. <view class="lf-iconfont icon-erweima lf-color-white"></view>
  28. <view class="lf-font-24 lf-color-white">支付码</view>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="lf-flex lf-row-between center-tag">
  33. <view class="lf-row-center lf-flex-column" @click="$url('/pages/point/detail/detail')">
  34. <view class="lf-font-36 lf-color-white">{{centerInfo.point || 0}}</view>
  35. <view class="lf-font-24 lf-color-white">积分</view>
  36. </view>
  37. <view class="lf-row-center lf-flex-column" @click="$url('/pages/recharge/balance/balance')">
  38. <view class="lf-font-36 lf-color-white">{{centerInfo.balance || 0}}</view>
  39. <view class="lf-font-24 lf-color-white">余额()</view>
  40. </view>
  41. <view class="lf-row-center lf-flex-column" @click="$url('/pages/coupon/index/index')">
  42. <view class="lf-font-36 lf-color-white">{{centerInfo.couponCount || 0}}</view>
  43. <view class="lf-font-24 lf-color-white">优惠券</view>
  44. </view>
  45. </view>
  46. </view>
  47. <view class="center-card" v-if="$isRight(centerInfo.userLevel)">
  48. <view class="lf-p-30 lf-row-between lf-w-100" @click="$url('/pages/user/member/service')">
  49. <view class="lf-flex-column">
  50. <view class="lf-font-bold" style="color: #15716E;">
  51. <text class="lf-font-48">VIP</text>
  52. <text class="lf-font-30 lf-m-l-10">{{ centerInfo.userLevel.name }}</text>
  53. </view>
  54. <!-- <view class="lf-font-28" style="color: #15716E;">卡号: 666666</view> -->
  55. </view>
  56. <view class="card-tag">
  57. 会员服务
  58. </view>
  59. </view>
  60. </view>
  61. <view class="lf-row-center">
  62. <view class="order-card">
  63. <view class="lf-row-between">
  64. <view class="lf-color-black lf-font-32 lf-font-bold">
  65. 商城订单
  66. </view>
  67. <view class="lf-flex" @click="$url('/pages/order/index/onlineorder')">
  68. <view class="lf-font-24 lf-color-777">全部订单</view>
  69. <text class="lf-iconfont icon-xiangyou lf-font-20 lf-m-l-10 lf-color-777"></text>
  70. </view>
  71. </view>
  72. <view class="order-tag lf-flex-wrap">
  73. <view class="order-children" @click="$url('/pages/order/index/onlineorder?current=1')">
  74. <view>
  75. <view class="function-tag" v-if="centerInfo.newCount != 0 && $isRight(centerInfo)">{{centerInfo.newCount}}</view>
  76. <view class="lf-iconfont lf-font-50 icon-daifukuan"></view>
  77. </view>
  78. <view class="lf-color-black lf-font-28 lf-m-t-20">待付款</view>
  79. </view>
  80. <view class="order-children" @click="$url('/pages/order/index/onlineorder?current=2')">
  81. <view>
  82. <view class="function-tag" v-if="centerInfo.paidCount != 0 && $isRight(centerInfo)">{{centerInfo.paidCount}}</view>
  83. <view class="lf-iconfont lf-font-50 icon-31daifahuo"></view>
  84. </view>
  85. <view class="lf-color-black lf-font-28 lf-m-t-20">待发货</view>
  86. </view>
  87. <view class="order-children" @click="$url('/pages/order/index/onlineorder?current=3')">
  88. <view>
  89. <view class="function-tag" v-if="centerInfo.deliveredCount != 0 && $isRight(centerInfo)">{{centerInfo.deliveredCount}}</view>
  90. <view class="lf-iconfont lf-font-50 icon-daishouhuo"></view>
  91. </view>
  92. <view class="lf-color-black lf-font-28 lf-m-t-20">待收货</view>
  93. </view>
  94. <view class="order-children" @click="$url('/pages/order/index/onlineorder?current=4')">
  95. <view>
  96. <view class="function-tag" v-if="centerInfo.receiveCount != 0 && $isRight(centerInfo)">{{centerInfo.receiveCount}}</view>
  97. <view class="lf-iconfont lf-font-50 icon-tihuo"></view>
  98. </view>
  99. <view class="lf-color-black lf-font-28 lf-m-t-20">待提货</view>
  100. </view>
  101. <!-- <view class="order-children"
  102. v-for="(item, index) in order_tablist" :key="index"
  103. @click="$url(item.path)">
  104. <view class="lf-iconfont lf-font-50" :class="item.icon"></view>
  105. <view class="lf-color-black lf-font-28 lf-m-t-20">{{ item.name }}</view>
  106. </view> -->
  107. </view>
  108. </view>
  109. </view>
  110. <view class="lf-row-center">
  111. <view class="order-card1">
  112. <view class="lf-row-between">
  113. <view class="lf-color-black lf-font-32 lf-font-bold">
  114. 我的服务
  115. </view>
  116. <view></view>
  117. </view>
  118. <view class="order-tag lf-flex-wrap">
  119. <view class="order-children my-service"
  120. v-for="(item, index) in my_service_list" :key="index"
  121. @click="$url(item.path)">
  122. <!-- <view class="function-tag"></view> -->
  123. <view class="lf-iconfont lf-font-60" :class="item.icon"></view>
  124. <view class="lf-color-black lf-font-28 lf-m-t-20" style="white-space: nowrap">{{ item.name }}</view>
  125. </view>
  126. </view>
  127. </view>
  128. </view>
  129. <!-- 悬浮购物车入口 -->
  130. <view class="fixed-right">
  131. <view class="fixed-cart" hover-class="lf-opacity" @click="$url('/pages/store/cart/cart')">
  132. <text class="lf-iconfont icon-gouwulan icon-text"></text>
  133. <text class="tips">购物车</text>
  134. <block v-if="$isRight(car_num)">
  135. <view class="angle-mark" v-if="car_num<99">{{car_num || 0}}</view>
  136. <view class="angle-mark" v-else>99+</view>
  137. </block>
  138. </view>
  139. </view>
  140. <lf-tabbar></lf-tabbar>
  141. </view>
  142. </template>
  143. <script>
  144. import lfTabbar from '@/components/lf-tabbar/lf-tabbar.vue'
  145. import { getUrl, getUpdateUserInfo } from '@/common/js/utils.js';
  146. export default {
  147. components: {
  148. lfTabbar
  149. },
  150. data(){
  151. return {
  152. // {
  153. // name: '在线客服',
  154. // icon: 'icon-pinglun',
  155. // path: '/pages/user/my/chatonline'
  156. // },
  157. nav_bg_color: 'transparent' ,// 导航背景颜色
  158. order_tablist: [{
  159. name: '待付款',
  160. icon: 'icon-daifukuan',
  161. path: '/pages/order/index/onlineorder?current=1'
  162. },{
  163. name: '待发货',
  164. icon: 'icon-31daifahuo',
  165. path: '/pages/order/index/onlineorder?current=2'
  166. },{
  167. name: '待收货',
  168. icon: 'icon-daishouhuo',
  169. path: '/pages/order/index/onlineorder?current=3'
  170. },{
  171. name: '待提货',
  172. icon: 'icon-tihuo',
  173. path: '/pages/order/index/onlineorder?current=4'
  174. }],
  175. my_service_list: [{
  176. name: '会员服务',
  177. icon: 'icon-huiyuan4',
  178. path: '/pages/user/member/service'
  179. },{
  180. name: '我的收藏',
  181. icon: 'icon-Star',
  182. path: '/pages/user/my/collect'
  183. },{
  184. name: '地址管理',
  185. icon: 'icon-Location',
  186. path: '/pages/address/list/list'
  187. },{
  188. name: '活动报名',
  189. icon: 'icon-Bookmark',
  190. path: '/pages/user/my/myEventRegistrationList'
  191. },{
  192. name: '积分商城订单',
  193. icon: 'icon-zhuanjifen',
  194. path: '/pages/point/exchangeRecord/exchangeRecord'
  195. },{
  196. name: '商家中心',
  197. icon: 'icon-dianshangjiashangcheng-xianxing',
  198. path: '/pages/business/center/center'
  199. }],
  200. userInfo: {mobile_replace: '正在获取'}, // 用户信息
  201. token: '', // 用户token
  202. code: '',
  203. centerInfo: {},
  204. show_count: 0,
  205. car_num: 0
  206. }
  207. },
  208. onLoad(){
  209. var token = this.$cookieStorage.get('user_token');
  210. this.token = token;
  211. if (token) {
  212. // #ifdef MP-WEIXIN
  213. if (this.code) {
  214. uni.checkSession({
  215. success: res => {
  216. if (res.errMsg != 'checkSession:ok') {
  217. this.getCode();
  218. }
  219. }
  220. });
  221. } else {
  222. this.getCode();
  223. }
  224. // #endif
  225. }
  226. this.getMeInfo();
  227. this.getUcenter();
  228. this.getcarNum();
  229. },
  230. onShow(){
  231. this.show_count++;
  232. if(this.show_count > 1){
  233. var token = this.$cookieStorage.get('user_token');
  234. this.token = token || '';
  235. this.getMeInfo();
  236. this.getUcenter();
  237. }
  238. },
  239. // 页面滚动
  240. onPageScroll(event){
  241. if(event.scrollTop >= 50){
  242. this.nav_bg_color = '#22A2A0';
  243. }else{
  244. this.nav_bg_color = 'transparent';
  245. }
  246. },
  247. methods: {
  248. getcarNum() {
  249. this.$http
  250. .get({
  251. api: 'api/shopping/cart/count',
  252. header: {
  253. Authorization: this.$cookieStorage.get('user_token')
  254. },
  255. })
  256. .then(res => {
  257. if (res.data.code == 200) {
  258. if(res.data.data == null) {
  259. this.car_num = 0;
  260. }else {
  261. this.car_num = res.data.data;
  262. }
  263. } else {
  264. wx.showModal({
  265. content: '请下拉页面刷新重试',
  266. showCancel: false
  267. });
  268. }
  269. })
  270. .catch(() => {
  271. wx.stopPullDownRefresh();
  272. wx.hideLoading();
  273. wx.showModal({
  274. content: '请求失败',
  275. showCancel: false
  276. });
  277. });
  278. },
  279. // 获取页面信息
  280. getMeInfo(){
  281. this.$http.get({
  282. api: 'api/me',
  283. header: {
  284. Authorization: this.token
  285. }
  286. }).then(res => {
  287. console.log("---", res);
  288. this.userInfo = res.data.data;
  289. })
  290. },
  291. // 获取积分等信息
  292. getUcenter(){
  293. this.$http.get({
  294. api: 'api/users/ucenter',
  295. header: {
  296. Authorization: this.token
  297. }
  298. }).then(res => {
  299. console.log("getUcenter", res);
  300. this.centerInfo = res.data.data;
  301. })
  302. },
  303. // 用户点击了自己的头像,此时做判断,已有头像就跳转到设置页,没有则授权获取用户微信信息
  304. clickAvatar(){
  305. if(this.token && this.userInfo.avatar){
  306. this.$url('/pages/user/my/setting');
  307. }else{
  308. uni.getUserProfile({
  309. desc: '获取你的昵称、头像、地区及性别',
  310. lang: 'zh_CN',
  311. complete: result => {
  312. console.log("result", result)
  313. if(result.errMsg == 'getUserProfile:ok'){
  314. let options = {
  315. iv: result.iv,
  316. encryptedData: result.encryptedData,
  317. code: this.code
  318. };
  319. this.updateUserInfo(options);
  320. }
  321. }
  322. })
  323. }
  324. },
  325. // 点击手机号,如果没有登录,则跳转到登录
  326. clickMobile(){
  327. if(this.token){
  328. this.$url('/pages/user/my/setting');
  329. }else{
  330. let url = getUrl();
  331. this.$url('/pages/user/register/register?url=' + url);
  332. }
  333. },
  334. // 静默登录获取code
  335. getCode(){
  336. uni.login({
  337. success: res => {
  338. if (res.code) {
  339. this.code = res.code;
  340. }
  341. }
  342. });
  343. },
  344. // 更新用户信息
  345. updateUserInfo(data){
  346. uni.showLoading({
  347. title: '完善信息中',
  348. mask: true
  349. });
  350. this.$http.get({
  351. api: 'api/user/bindUserMiniInfo',
  352. data: data,
  353. header: {
  354. Authorization: this.token
  355. }
  356. }).then(res => {
  357. res = res.data;
  358. if (res.status) {
  359. // #ifdef MP-WEIXIN
  360. getUpdateUserInfo(this.token);
  361. // #endif
  362. uni.hideLoading();
  363. } else {
  364. uni.showModal({
  365. content: res.message || '请求失败',
  366. showCancel: false
  367. });
  368. this.getCode();
  369. uni.hideLoading();
  370. }
  371. uni.hideLoading();
  372. }).catch(rej=>{
  373. uni.showModal({
  374. content: rej.message || '请求失败',
  375. showCancel: false
  376. });
  377. uni.hideLoading();
  378. });
  379. }
  380. }
  381. }
  382. </script>
  383. <style>
  384. page{
  385. overflow-x: hidden;
  386. }
  387. </style>
  388. <style lang="scss" scoped>
  389. .fixed-right{
  390. position: fixed;
  391. right: 32rpx;
  392. bottom: 400rpx;
  393. width: max-content;
  394. height: max-content;
  395. z-index: 9;
  396. .fixed-cart{
  397. width: 110rpx;
  398. height: 110rpx;
  399. border-radius: 50%;
  400. background-color: #FFFFFF;
  401. border: 1rpx solid #DEDEDE;
  402. display: flex;
  403. justify-content: center;
  404. align-items: center;
  405. flex-direction: column;
  406. color: #333333;
  407. position: relative;
  408. margin-top: 30rpx;
  409. .icon-text{
  410. font-size: 50rpx;
  411. line-height: 1;
  412. }
  413. .tips{
  414. font-size: 20rpx;
  415. color: #333333;
  416. }
  417. .angle-mark{
  418. position: absolute;
  419. right: 4rpx;
  420. top: 4rpx;
  421. width: 40rpx;
  422. height: 40rpx;
  423. background-color: #15716E;
  424. border-radius: 50%;
  425. font-size: 20rpx;
  426. display: flex;
  427. justify-content: center;
  428. align-items: center;
  429. color: #FFFFFF;
  430. }
  431. }
  432. .fixed-live{
  433. background: #15716E;
  434. border-radius: 100rpx 5rpx 100rpx 100rpx;
  435. border: none;
  436. color: #FFFFFF;
  437. // animation: bounceIn 1s .2s ease both;
  438. backface-visibility:visible;
  439. transform-origin:center center;
  440. animation: demo 2s 0s infinite ease normal none ;
  441. // &>text:nth-child(1){
  442. // animation: fadeInRightBig 1s .1s ease both;
  443. // }
  444. .tips{
  445. color: #FFFFFF;
  446. }
  447. }
  448. }
  449. .order-children {
  450. width: 134rpx;
  451. position: relative;
  452. height: 100%;
  453. display: flex;
  454. flex-direction: column;
  455. justify-content: center;
  456. align-items: center;
  457. margin-right: 27rpx;
  458. &>view:nth-child(1){
  459. line-height: 1;
  460. }
  461. &:nth-child(4n) {
  462. margin-right: 0;
  463. }
  464. &:nth-child(n + 5) {
  465. margin-top: 50rpx;
  466. }
  467. }
  468. .my-service{
  469. width: 190rpx;
  470. &>view:nth-child(1){
  471. line-height: 1;
  472. }
  473. &:nth-child(3n){
  474. margin-right: 0;
  475. }
  476. &:nth-child(4n) {
  477. margin-right: 27rpx;
  478. }
  479. &:nth-child(n+4){
  480. margin-top: 50rpx;
  481. }
  482. }
  483. .function-tag {
  484. color: white;
  485. font-size: 24rpx;
  486. position: absolute;
  487. right: 18rpx;
  488. width: 39rpx;
  489. height: 40rpx;
  490. background: red;
  491. top: -12rpx;
  492. border-radius: 50%;
  493. display: flex;
  494. align-items: center;
  495. justify-content: center;
  496. }
  497. .order-tag {
  498. padding: 50rpx 0;
  499. display: flex;
  500. flex: wrap;
  501. // justify-content: space-around;
  502. align-items: center;
  503. }
  504. .order-card {
  505. padding: 30rpx 30rpx 0 30rpx;
  506. width: 686rpx;
  507. height: 100%;
  508. background: #FFFFFF;
  509. box-shadow: 0rpx 2rpx 8rpx 1rpx rgba(0, 0, 0, 0.1);
  510. border-radius: 20rpx;
  511. // margin: 150rpx 0 30rpx 0;
  512. margin: 30rpx 0 30rpx 0;
  513. }
  514. .order-card1 {
  515. padding: 30rpx 30rpx 0 30rpx;
  516. width: 686rpx;
  517. height: 100%;
  518. background: #FFFFFF;
  519. box-shadow: 0rpx 2rpx 8rpx 1rpx rgba(0, 0, 0, 0.1);
  520. border-radius: 20rpx;
  521. margin-bottom: 30rpx;
  522. }
  523. .card-tag {
  524. width: 144rpx;
  525. height: 53rpx;
  526. background: linear-gradient(90deg, #22A2A0 0%, #187B7A 100%);
  527. border-radius: 30rpx;
  528. display: flex;
  529. align-items: center;
  530. color: white;
  531. justify-content: center;
  532. font-size: 26rpx;
  533. }
  534. .center-card {
  535. width: 686rpx;
  536. height: 160rpx;
  537. background: #FFFFFF;
  538. display: flex;
  539. align-items: center;
  540. box-shadow: 0rpx 2rpx 8rpx 1rpx rgba(0, 0, 0, 0.1);
  541. border-radius: 20rpx;
  542. margin: -40rpx auto 0;
  543. position: relative;
  544. z-index: 9;
  545. // position: absolute;
  546. // bottom: -120rpx;
  547. // left: 32rpx;
  548. // z-index: 9999;
  549. }
  550. .center-tag {
  551. padding: 0 80rpx 0 80rpx;
  552. position: relative;
  553. z-index: 9;
  554. }
  555. .ocupy {
  556. height: 160rpx;
  557. width: 100%;
  558. }
  559. .center-top {
  560. position: relative;
  561. width: 750rpx;
  562. height: 512rpx;
  563. background: linear-gradient(90deg, #22A2A0 0%, #187B7A 100%);
  564. overflow: hidden;
  565. .bg-left{
  566. position: absolute;
  567. width: 196rpx;
  568. height: 196rpx;
  569. border-radius: 50%;
  570. background-color: rgba(255,255,255,0.04);
  571. left: -92rpx;
  572. bottom: 60rpx;
  573. }
  574. .bg-right{
  575. position: absolute;
  576. width: 520rpx;
  577. height: 520rpx;
  578. border-radius: 50%;
  579. background-color: rgba(255,255,255,0.04);
  580. right: -168rpx;
  581. top: -122rpx;
  582. }
  583. }
  584. .center-img {
  585. width: 100rpx;
  586. height: 100rpx;
  587. border: 2rpx solid #FFFFFF;
  588. border-radius: 100%;
  589. }
  590. </style>