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

457 lines
12 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="aspectFill" class="center-img" v-if="userInfo.avatar"></image>
  12. <image src="/static/images/empty.png" mode="aspectFill" 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(item.path)">
  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. <lf-tabbar></lf-tabbar>
  103. </view>
  104. </template>
  105. <script>
  106. import lfTabbar from '@/components/lf-tabbar/lf-tabbar.vue'
  107. import { getUrl, getUpdateUserInfo } from '@/common/js/utils.js';
  108. export default {
  109. components: {
  110. lfTabbar
  111. },
  112. data(){
  113. return {
  114. // {
  115. // name: '在线客服',
  116. // icon: 'icon-pinglun',
  117. // path: '/pages/user/my/chatonline'
  118. // },
  119. nav_bg_color: 'transparent' ,// 导航背景颜色
  120. order_tablist: [{
  121. name: '待付款',
  122. icon: 'icon-daifukuan',
  123. path: '/pages/order/index/onlineorder?current=1'
  124. },{
  125. name: '待发货',
  126. icon: 'icon-31daifahuo',
  127. path: '/pages/order/index/onlineorder?current=2'
  128. },{
  129. name: '待收货',
  130. icon: 'icon-daishouhuo',
  131. path: '/pages/order/index/onlineorder?current=3'
  132. },{
  133. name: '待提货',
  134. icon: 'icon-tihuo',
  135. path: '/pages/order/index/onlineorder?current=4'
  136. }],
  137. my_service_list: [{
  138. name: '会员服务',
  139. icon: 'icon-huiyuan4',
  140. path: '/pages/user/member/service'
  141. },{
  142. name: '我的收藏',
  143. icon: 'icon-Star',
  144. path: '/pages/user/my/collect'
  145. },{
  146. name: '地址管理',
  147. icon: 'icon-Location',
  148. path: '/pages/address/list/list'
  149. },{
  150. name: '活动报名',
  151. icon: 'icon-Bookmark',
  152. path: '/pages/user/my/myEventRegistrationList'
  153. },{
  154. name: '积分商城订单',
  155. icon: 'icon-zhuanjifen',
  156. path: '/pages/point/exchangeRecord/exchangeRecord'
  157. },{
  158. name: '商家中心',
  159. icon: 'icon-dianshangjiashangcheng-xianxing',
  160. path: '/pages/business/center/center'
  161. }],
  162. userInfo: {mobile_replace: '正在获取'}, // 用户信息
  163. token: '', // 用户token
  164. code: '',
  165. centerInfo: {},
  166. show_count: 0
  167. }
  168. },
  169. onLoad(){
  170. var token = this.$cookieStorage.get('user_token');
  171. this.token = token;
  172. if (token) {
  173. // #ifdef MP-WEIXIN
  174. if (this.code) {
  175. uni.checkSession({
  176. success: res => {
  177. if (res.errMsg != 'checkSession:ok') {
  178. this.getCode();
  179. }
  180. }
  181. });
  182. } else {
  183. this.getCode();
  184. }
  185. // #endif
  186. }
  187. this.getMeInfo();
  188. this.getUcenter();
  189. },
  190. onShow(){
  191. this.show_count++;
  192. if(this.show_count > 1){
  193. var token = this.$cookieStorage.get('user_token');
  194. this.token = token || '';
  195. this.getMeInfo();
  196. this.getUcenter();
  197. }
  198. },
  199. // 页面滚动
  200. onPageScroll(event){
  201. if(event.scrollTop >= 50){
  202. this.nav_bg_color = '#22A2A0';
  203. }else{
  204. this.nav_bg_color = 'transparent';
  205. }
  206. },
  207. methods: {
  208. // 获取页面信息
  209. getMeInfo(){
  210. this.$http.get({
  211. api: 'api/me',
  212. header: {
  213. Authorization: this.token
  214. }
  215. }).then(res => {
  216. console.log("---", res);
  217. this.userInfo = res.data.data;
  218. })
  219. },
  220. // 获取积分等信息
  221. getUcenter(){
  222. this.$http.get({
  223. api: 'api/users/ucenter',
  224. header: {
  225. Authorization: this.token
  226. }
  227. }).then(res => {
  228. console.log("getUcenter", res);
  229. this.centerInfo = res.data.data;
  230. })
  231. },
  232. // 用户点击了自己的头像,此时做判断,已有头像就跳转到设置页,没有则授权获取用户微信信息
  233. clickAvatar(){
  234. if(this.token && this.userInfo.avatar){
  235. this.$url('/pages/user/my/setting');
  236. }else{
  237. uni.getUserProfile({
  238. desc: '获取你的昵称、头像、地区及性别',
  239. lang: 'zh_CN',
  240. complete: result => {
  241. console.log("result", result)
  242. if(result.errMsg == 'getUserProfile:ok'){
  243. let options = {
  244. iv: result.iv,
  245. encryptedData: result.encryptedData,
  246. code: this.code
  247. };
  248. this.updateUserInfo(options);
  249. }
  250. }
  251. })
  252. }
  253. },
  254. // 点击手机号,如果没有登录,则跳转到登录
  255. clickMobile(){
  256. if(this.token){
  257. this.$url('/pages/user/my/setting');
  258. }else{
  259. let url = getUrl();
  260. this.$url('/pages/user/register/register?url=' + url);
  261. }
  262. },
  263. // 静默登录获取code
  264. getCode(){
  265. uni.login({
  266. success: res => {
  267. if (res.code) {
  268. this.code = res.code;
  269. }
  270. }
  271. });
  272. },
  273. // 更新用户信息
  274. updateUserInfo(data){
  275. uni.showLoading({
  276. title: '完善信息中',
  277. mask: true
  278. });
  279. this.$http.get({
  280. api: 'api/user/bindUserMiniInfo',
  281. data: data,
  282. header: {
  283. Authorization: this.token
  284. }
  285. }).then(res => {
  286. res = res.data;
  287. if (res.status) {
  288. // #ifdef MP-WEIXIN
  289. getUpdateUserInfo(this.token);
  290. // #endif
  291. uni.hideLoading();
  292. } else {
  293. uni.showModal({
  294. content: res.message || '请求失败',
  295. showCancel: false
  296. });
  297. this.getCode();
  298. uni.hideLoading();
  299. }
  300. uni.hideLoading();
  301. }).catch(rej=>{
  302. uni.showModal({
  303. content: rej.message || '请求失败',
  304. showCancel: false
  305. });
  306. uni.hideLoading();
  307. });
  308. }
  309. }
  310. }
  311. </script>
  312. <style>
  313. page{
  314. overflow-x: hidden;
  315. }
  316. </style>
  317. <style lang="scss" scoped>
  318. .order-children {
  319. width: 134rpx;
  320. height: 100%;
  321. display: flex;
  322. flex-direction: column;
  323. justify-content: center;
  324. align-items: center;
  325. margin-right: 27rpx;
  326. &>view:nth-child(1){
  327. line-height: 1;
  328. }
  329. &:nth-child(4n) {
  330. margin-right: 0;
  331. }
  332. &:nth-child(n + 5) {
  333. margin-top: 50rpx;
  334. }
  335. }
  336. .my-service{
  337. width: 190rpx;
  338. &>view:nth-child(1){
  339. line-height: 1;
  340. }
  341. &:nth-child(3n){
  342. margin-right: 0;
  343. }
  344. &:nth-child(4n) {
  345. margin-right: 27rpx;
  346. }
  347. &:nth-child(n+4){
  348. margin-top: 50rpx;
  349. }
  350. }
  351. .function-tag {
  352. width: 50rpx;
  353. height: 50rpx;
  354. background: #D8D8D8;
  355. border: 1rpx solid #979797;
  356. border-radius: 50%;
  357. }
  358. .order-tag {
  359. padding: 50rpx 0;
  360. display: flex;
  361. flex: wrap;
  362. // justify-content: space-around;
  363. align-items: center;
  364. }
  365. .order-card {
  366. padding: 30rpx 30rpx 0 30rpx;
  367. width: 686rpx;
  368. height: 100%;
  369. background: #FFFFFF;
  370. box-shadow: 0rpx 2rpx 8rpx 1rpx rgba(0, 0, 0, 0.1);
  371. border-radius: 20rpx;
  372. // margin: 150rpx 0 30rpx 0;
  373. margin: 30rpx 0 30rpx 0;
  374. }
  375. .order-card1 {
  376. padding: 30rpx 30rpx 0 30rpx;
  377. width: 686rpx;
  378. height: 100%;
  379. background: #FFFFFF;
  380. box-shadow: 0rpx 2rpx 8rpx 1rpx rgba(0, 0, 0, 0.1);
  381. border-radius: 20rpx;
  382. margin-bottom: 30rpx;
  383. }
  384. .card-tag {
  385. width: 144rpx;
  386. height: 53rpx;
  387. background: linear-gradient(90deg, #22A2A0 0%, #187B7A 100%);
  388. border-radius: 30rpx;
  389. display: flex;
  390. align-items: center;
  391. color: white;
  392. justify-content: center;
  393. font-size: 26rpx;
  394. }
  395. .center-card {
  396. width: 686rpx;
  397. height: 160rpx;
  398. background: #FFFFFF;
  399. display: flex;
  400. align-items: center;
  401. box-shadow: 0rpx 2rpx 8rpx 1rpx rgba(0, 0, 0, 0.1);
  402. border-radius: 20rpx;
  403. margin: -40rpx auto 0;
  404. position: relative;
  405. z-index: 9;
  406. // position: absolute;
  407. // bottom: -120rpx;
  408. // left: 32rpx;
  409. // z-index: 9999;
  410. }
  411. .center-tag {
  412. padding: 0 80rpx 0 80rpx;
  413. position: relative;
  414. z-index: 9;
  415. }
  416. .ocupy {
  417. height: 160rpx;
  418. width: 100%;
  419. }
  420. .center-top {
  421. position: relative;
  422. width: 750rpx;
  423. height: 512rpx;
  424. background: linear-gradient(90deg, #22A2A0 0%, #187B7A 100%);
  425. overflow: hidden;
  426. .bg-left{
  427. position: absolute;
  428. width: 196rpx;
  429. height: 196rpx;
  430. border-radius: 50%;
  431. background-color: rgba(255,255,255,0.04);
  432. left: -92rpx;
  433. bottom: 60rpx;
  434. }
  435. .bg-right{
  436. position: absolute;
  437. width: 520rpx;
  438. height: 520rpx;
  439. border-radius: 50%;
  440. background-color: rgba(255,255,255,0.04);
  441. right: -168rpx;
  442. top: -122rpx;
  443. }
  444. }
  445. .center-img {
  446. width: 100rpx;
  447. height: 100rpx;
  448. border: 2rpx solid #FFFFFF;
  449. border-radius: 100%;
  450. }
  451. </style>