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

453 lines
12 KiB

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