mine.vue 13 KB

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