金诚优选前端代码
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.

594 lines
16 KiB

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