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

444 lines
11 KiB

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