mine.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. <template>
  2. <view >
  3. <!-- 扫一扫错误回调 -->
  4. <u-modal title="扫描异常" confirm-color="#dc9b21" v-model="scanNotify.scan" :content="scanNotify.scanMessage"></u-modal>
  5. <view style="position: relative;">
  6. <image src="@/static/icon/bg.png" class="bg-img"></image>
  7. <image src="@/static/icon/bg-yin.png" class="shuiyin" mode=""></image>
  8. <view class="card">
  9. <view class="info" v-if="vuex_userId">
  10. <view class="flex">
  11. <image class="avatar" :src="userInfo.avatar"></image>
  12. <view class="nickname">
  13. <block style="display: flex;">
  14. <text >{{userInfo.nickName}}</text>
  15. <view v-if="vuex_agenter_type!= '普通用户'" class="cu-tag bg-red sm radius margin-left-20">
  16. <text>{{vuex_agenter_type}}</text>
  17. </view>
  18. </block>
  19. </view>
  20. </view>
  21. </view>
  22. <view class="info" v-else>
  23. <view class="flex">
  24. <image class="avatar" src="/static/icon/avatar.png"></image>
  25. <view class="nickname">
  26. <block style="display: flex;">
  27. <text >用户未登录</text>
  28. <view @click="showLogin" class="cu-tag bg-tag sm round margin-left-20">
  29. 点击登录
  30. </view>
  31. </block>
  32. </view>
  33. </view>
  34. </view>
  35. <view class="cu-list grid col-3 no-border" style="border-radius:20rpx ;">
  36. <view class="cu-item" @click="item.name=='扫一扫'? scanCode() :jump(item.path)" v-for="(item,index) in menuList" :key="index">
  37. <view class="grid-icon" >
  38. <image style="width: 66rpx;height: 66rpx;" :src="item.icon"/>
  39. </view>
  40. <text style="color: #242424;font-size: 26rpx;" >{{item.name}}</text>
  41. <view class="cu-tag bg-red badge" v-if="item.count>0">{{item.count}}</view>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. <view class="navbar-top" :style="{ 'background': 'rgba(255, 139, 47,'+toumindu+')'}">
  47. <view class="text-center text-white title ">联兑通</view>
  48. </view>
  49. <view class="account">
  50. <text class="title">我的账户</text>
  51. <view class="menu">
  52. <view class="item" @click="jump('/pagesA/pages/my-points/my-points?point='+userInfo.channelPoint)">
  53. <text>{{userInfo.channelPoint || 0}}</text>
  54. 通兑积分
  55. </view>
  56. <view class="item" @click="jump('/pagesA/pages/my-balance/my-balance?pointValue='+userInfo.balance)">
  57. <text>{{userInfo.balance || 0}}</text>
  58. 积分余额
  59. </view>
  60. </view>
  61. </view>
  62. <view class="exchange">
  63. <view class="top" style="padding: 20rpx 30rpx 10rpx;">
  64. <text>积分通兑</text>
  65. <text @click="jump('/pagesA/pages/my-points/exchange')">更多 ></text>
  66. </view>
  67. <view class="menu-list">
  68. <view class="item item1">
  69. <image src="@/static/icon/jiayou.png" mode=""></image>
  70. <text class="title" style="color: #F6532A;">积分加油站</text>
  71. <view class="cu-btn round sm" >
  72. 去充值
  73. </view>
  74. </view>
  75. <view class="item item2">
  76. <image src="@/static/icon/yidong.png" mode=""></image>
  77. <text class="title" style="color: #4AB0FF;">中国移动</text>
  78. <view class="cu-btn round sm" >
  79. 120:100兑入
  80. </view>
  81. </view>
  82. <view class="item item3">
  83. <image src="@/static/icon/BOC.png" mode=""></image>
  84. <text class="title" style="color: #CF4948;">中国银行</text>
  85. <view class="cu-btn round sm">
  86. 530:100兑入
  87. </view>
  88. </view>
  89. </view>
  90. </view>
  91. <view class="consume" v-if="false">
  92. <view class="top" style="padding: 20rpx 30rpx 10rpx;">
  93. <text>赚积分</text>
  94. <text>更多 ></text>
  95. </view>
  96. <view class="cu-list grid col-3 no-border" style="border-radius:20rpx ;">
  97. <view class="cu-item" @click="jump(item.path)" v-for="(item,index) in gainList" :key="index">
  98. <view class="grid-icon" >
  99. <image style="width: 160rpx;height: 160rpx;border-radius: 16rpx;" :src="item.icon"/>
  100. </view>
  101. <text style="color: #222222;font-size: 26rpx;" >{{item.name}}</text>
  102. <view class="cu-tag bg-red badge" v-if="item.count>0">{{item.count}}</view>
  103. </view>
  104. </view>
  105. </view>
  106. <view class="consume" @click="jump('/pages/gain/gain',1)">
  107. <view class="top" style="padding: 20rpx 30rpx 10rpx;">
  108. <text>去花积分</text>
  109. <text>更多 ></text>
  110. </view>
  111. <view class="cu-list grid col-4 no-border" style="border-radius:20rpx ;">
  112. <view class="cu-item" @click.stop="jumpMiniProgram(item.path)" v-for="(item,index) in pointsList" :key="index">
  113. <view class="grid-icon" >
  114. <image style="width: 88rpx;height: 88rpx;" :src="item.icon"/>
  115. </view>
  116. <text style="color: #222222;font-size: 26rpx;" >{{item.name}}</text>
  117. <view class="cu-tag bg-red badge" v-if="item.count>0">{{item.count}}</view>
  118. </view>
  119. </view>
  120. </view>
  121. <login ref="login" @signIn="signIn"></login>
  122. </view>
  123. </template>
  124. <script>
  125. import login from "@/components/login.vue"
  126. export default {
  127. components:{
  128. login
  129. },
  130. data() {
  131. return {
  132. scanNotify:{scan: false,scanMessage:'扫描错误,请稍后重试!' },
  133. toumindu: 0.00,
  134. //功能列表
  135. menuList:[],
  136. gainList:[],
  137. pointsList:[],
  138. //用户信息
  139. userInfo:{},
  140. //跳回收银台的逻辑
  141. query:''
  142. }
  143. },
  144. onPageScroll(obj){
  145. this.toumindu = obj.scrollTop*0.006;
  146. },
  147. onLoad(options) {
  148. uni.hideLoading()
  149. //获取从收银台传过来的参数,处理新用户扫码进入收银台再进入首页的情况
  150. if (!this.$isEmpty(options.query)) {
  151. this.query=options.query
  152. }
  153. },
  154. onShow() {
  155. uni.hideLoading()
  156. this.fetchStatic()
  157. this.login()
  158. },
  159. methods: {
  160. init(){
  161. this.fetchUserInfo()
  162. },
  163. async fetchUserInfo(){
  164. let params={
  165. id:this.vuex_userId
  166. }
  167. this.$api.loginUser.detail(params).then(res=>{
  168. if (this.$isEmpty(res.data)) {
  169. this.handeGetUserInfoError()
  170. }else{
  171. this.userInfo=res.data
  172. this.$u.vuex('vuex_agenter_type',res.data.userType)
  173. }
  174. }).catch(err=>{
  175. this.handeGetUserInfoError()
  176. })
  177. },
  178. handeGetUserInfoError(){
  179. //清除userId和手机号
  180. this.$u.vuex('vuex_userId',null)
  181. this.$u.vuex('vuex_phone',null)
  182. this.$cache.remove('lifeData')
  183. this.$cache.remove('userInfo')
  184. //刷新当前页
  185. this.login()
  186. },
  187. // 登录 begin
  188. showLogin(){
  189. this.$refs.login.show()
  190. },
  191. showPhoneModal(){
  192. this.$refs.login.showPhoneModal()
  193. },
  194. signIn(resp){
  195. //获取手机号
  196. if (this.$isEmpty(this.vuex_phone)) {
  197. this.showPhoneModal()
  198. }else{
  199. this.$u.toast('登录成功')
  200. }
  201. //获取数据
  202. this.init()
  203. // #ifdef MP-WEIXIN
  204. //处理跳回收银台的情况
  205. if (!this.$isEmpty(this.query)) {
  206. uni.redirectTo({
  207. url:"/pagesC/pages/checkstand/index?query="+this.query
  208. })
  209. }
  210. // #endif
  211. },
  212. async login(e){
  213. if (this.$isEmpty(this.vuex_userId)) {
  214. this.showLogin()
  215. return
  216. }
  217. //获取数据
  218. this.init()
  219. //获取手机号
  220. if (this.$isEmpty(this.vuex_phone)) {
  221. this.showPhoneModal()
  222. }
  223. },
  224. // 登录 end
  225. scanCode(){
  226. const _this = this;
  227. uni.scanCode({
  228. success: function (res) {
  229. console.log(res);
  230. let result=res.result
  231. let url=result.split("#")[1]
  232. _this.jump(url)
  233. },
  234. fail: (res) => {
  235. console.log(res);
  236. if(res.errMsg!='scanCode:fail cancel'){
  237. this.scanNotify = {scan: true,scanMessage: res.errMsg};
  238. }
  239. }
  240. });
  241. },
  242. jump(url,type){
  243. if (type==1) {
  244. uni.switchTab({
  245. url
  246. })
  247. return
  248. }
  249. if (this.$isEmpty(this.vuex_userId)) {
  250. console.log("123");
  251. this.login()
  252. return
  253. }
  254. uni.navigateTo({
  255. url
  256. })
  257. },
  258. jumpMiniProgram(appid,path){
  259. this.$mpi.navigateToMiniProgram(appid)
  260. },
  261. fetchStatic(){
  262. this.menuList=[
  263. {
  264. icon:'/static/icon/scan.png',
  265. name:'扫一扫',
  266. path:'/pagesC/pages/checkstand/index'
  267. },
  268. {
  269. icon:'/static/icon/pay.png',
  270. name:'付款码',
  271. path:'/pagesC/pages/checkstand/pay-qrcode'
  272. },
  273. {
  274. icon:'/static/icon/setting1.png',
  275. name:'设置',
  276. path:'/pagesA/pages/setting/setting'
  277. }
  278. ]
  279. this.gainList=[
  280. {
  281. icon:'/static/icon/daili.png',
  282. name:'成为代理',
  283. path:'/pages/mine/card/card'
  284. },
  285. {
  286. icon:'/static/icon/xianfeng.png',
  287. name:'音乐先锋榜',
  288. path:'/pages/mine/card/card'
  289. },
  290. {
  291. icon:'/static/icon/xianfeng.png',
  292. name:'音乐先锋榜',
  293. path:'/pages/mine/card/card'
  294. },
  295. ]
  296. this.pointsList=[
  297. {
  298. icon:'/static/icon/life.png',
  299. name:'生活服务',
  300. path:''
  301. },
  302. {
  303. icon:'/static/icon/jiaotong.png',
  304. name:'交通出行',
  305. path:this.$global.APPID.didi
  306. },
  307. {
  308. icon:'/static/icon/shop.png',
  309. name:'购物',
  310. path:''
  311. },
  312. {
  313. icon:'/static/icon/yiyao.png',
  314. name:'医疗',
  315. path:this.$global.APPID.nanyue
  316. },
  317. ]
  318. }
  319. }
  320. }
  321. </script>
  322. <style lang="scss" scoped>
  323. .bg-tag{
  324. color: #FFFFFF;
  325. background-color: #EA3723;
  326. }
  327. .shuiyin{
  328. overflow: hidden;
  329. width: 260rpx;
  330. height: 280rpx;
  331. position: absolute;
  332. right: 10rpx;
  333. top: 30rpx;
  334. }
  335. .bg-img{
  336. width: 100vw;
  337. height: 420rpx;
  338. }
  339. .navbar-top{
  340. position: fixed;
  341. width: 100%;
  342. top: 0;
  343. z-index:99999;
  344. padding-top:var(--status-bar-height);
  345. transition: top .25s;
  346. .title{
  347. padding: 18.18rpx 0;
  348. }
  349. }
  350. .card{
  351. position: relative;
  352. margin: -240rpx 20rpx 0;
  353. border-radius: 20rpx;
  354. background-color: #FFFFFF;
  355. .info{
  356. padding: 20rpx 20rpx 0;
  357. display: flex;
  358. justify-content: space-between;
  359. .avatar{
  360. width: 100rpx;
  361. height: 100rpx;
  362. border-radius: 50%;
  363. }
  364. .nickname{
  365. font-weight: 800;
  366. color: #222222;
  367. font-size: 30rpx;
  368. margin-left: 20rpx;
  369. display: flex;
  370. align-items: center;
  371. justify-content: center;
  372. }
  373. }
  374. }
  375. .account{
  376. padding: 20rpx;
  377. color: #222222;
  378. margin: 20rpx;
  379. border-radius: 20rpx;
  380. background-color: #FFFFFF;
  381. .title{
  382. padding-left: 20rpx;
  383. font-weight: 800;
  384. font-size: 34rpx;
  385. color: #26272F;
  386. }
  387. .menu{
  388. display: flex;
  389. justify-content: space-around;
  390. view{
  391. padding-top: 20rpx;
  392. display: flex;
  393. flex-direction: column;
  394. justify-content: center;
  395. align-items: center;
  396. text:first-child{
  397. font-weight: 800;
  398. padding-bottom: 10rpx;
  399. font-size: 32rpx;
  400. color: #FF9447;
  401. }
  402. text:last-child{
  403. }
  404. }
  405. }
  406. }
  407. .exchange{
  408. border-radius: 20rpx;
  409. background-color: #FFFFFF;
  410. padding: 10rpx 10rpx 30rpx;
  411. margin: 20rpx;
  412. .top{
  413. text:first-child{
  414. font-size: 34rpx;
  415. font-weight: 800;
  416. color: #26272F;
  417. }
  418. text:last-child{
  419. padding-top: 10rpx;
  420. font-size: 26rpx;
  421. color: #999999;
  422. }
  423. }
  424. .menu-list{
  425. display: flex;
  426. justify-content: space-around;
  427. .item{
  428. margin-top: 20rpx;
  429. width: 31%;
  430. padding: 15rpx 0;
  431. border-radius: 16rpx;
  432. display: flex;
  433. justify-content: center;
  434. align-items: center;
  435. flex-direction: column;
  436. .title{
  437. font-weight: 800;
  438. margin-bottom: 10rpx;
  439. }
  440. image{
  441. margin-bottom: 10rpx;
  442. border-radius: 50%;
  443. padding: 15rpx;
  444. background-color: #FFFFFF;
  445. width: 70rpx;
  446. height: 70rpx;
  447. }
  448. }
  449. .item1{
  450. background-image: linear-gradient(to right,#F7F0E7,#E9CEB9);
  451. view{
  452. font-size: 26rpx;
  453. padding: 10rpx 50rpx;
  454. background-color: #FF9447;
  455. color: #FFFFFF;
  456. }
  457. }
  458. .item2{
  459. background-image: linear-gradient(to right,#E8F2FC,#C3D5ED);
  460. view{
  461. font-size: 26rpx;
  462. padding: 10rpx 20rpx;
  463. background-color: #4AB0FF;
  464. color: #FFFFFF;
  465. }
  466. }
  467. .item3{
  468. background-image: linear-gradient(to right,#F7E9E9,#EAC4C3);
  469. view{
  470. font-size: 26rpx;
  471. padding: 10rpx 20rpx;
  472. background-color: #CF4948;
  473. color: #FFFFFF;
  474. }
  475. }
  476. }
  477. }
  478. .consume{
  479. border-radius: 20rpx;
  480. background-color: #FFFFFF;
  481. padding: 10rpx 10rpx 30rpx;
  482. margin: 20rpx;
  483. .top{
  484. text:first-child{
  485. font-size: 34rpx;
  486. font-weight: 800;
  487. color: #26272F;
  488. }
  489. text:last-child{
  490. padding-top: 10rpx;
  491. font-size: 26rpx;
  492. color: #999999;
  493. }
  494. }
  495. }
  496. .top{
  497. display: flex;
  498. justify-content: space-between;
  499. }
  500. </style>