mine.vue 12 KB

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