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

443 lines
11 KiB

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