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

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