mine.vue 12 KB

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