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

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