mine.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  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. // #ifdef MP-WEIXIN
  215. //处理跳回收银台的情况
  216. if (!this.$isEmpty(this.query)) {
  217. uni.redirectTo({
  218. url:"/pages/checkstand/index?query="+this.query
  219. })
  220. }
  221. // #endif
  222. },
  223. async login(e){
  224. if (this.$isEmpty(this.vuex_userId)) {
  225. this.showLogin()
  226. return
  227. }
  228. //获取数据
  229. this.init()
  230. //获取手机号
  231. if (this.$isEmpty(this.vuex_phone)) {
  232. this.showPhoneModal()
  233. }
  234. },
  235. // 登录 end
  236. scanCode(){
  237. const _this = this;
  238. uni.scanCode({
  239. success: function (res) {
  240. let result=res.result
  241. let url=result.split("#")[1]
  242. _this.jump(url)
  243. },
  244. fail: (res) => {
  245. if(res.errMsg!='scanCode:fail cancel'){
  246. this.scanNotify = {scan: true,scanMessage: res.errMsg};
  247. }
  248. }
  249. });
  250. },
  251. jump(url,type){
  252. if (type==1) {
  253. uni.switchTab({
  254. url
  255. })
  256. return
  257. }
  258. if (this.$isEmpty(this.vuex_userId)) {
  259. this.login()
  260. return
  261. }
  262. uni.navigateTo({
  263. url
  264. })
  265. },
  266. jumpMiniProgram(appid,path){
  267. this.$mpi.navigateToMiniProgram(appid)
  268. },
  269. fetchStatic(){
  270. this.menuList=[
  271. {
  272. icon:'/static/icon/scan.png',
  273. name:'扫一扫',
  274. path:'/pages/checkstand/index'
  275. },
  276. {
  277. icon:'/static/icon/pay.png',
  278. name:'付款码',
  279. path:'/pages/checkstand/pay-qrcode'
  280. },
  281. {
  282. icon:'/static/icon/setting1.png',
  283. name:'设置',
  284. path:'/pages/mine/setting/setting'
  285. }
  286. ]
  287. this.gainList=[
  288. {
  289. icon:'/static/icon/daili.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. icon:'/static/icon/xianfeng.png',
  300. name:'音乐先锋榜',
  301. path:'/pages/mine/card/card'
  302. },
  303. ]
  304. this.pointsList=[
  305. {
  306. icon:'/static/icon/life.png',
  307. name:'生活服务',
  308. path:''
  309. },
  310. {
  311. icon:'/static/icon/jiaotong.png',
  312. name:'交通出行',
  313. path:this.$global.APPID.didi
  314. },
  315. {
  316. icon:'/static/icon/shop.png',
  317. name:'购物',
  318. path:''
  319. },
  320. {
  321. icon:'/static/icon/yiyao.png',
  322. name:'医疗',
  323. path:this.$global.APPID.nanyue
  324. },
  325. ]
  326. }
  327. }
  328. }
  329. </script>
  330. <style lang="scss" scoped>
  331. .bg-tag{
  332. color: #FFFFFF;
  333. background-color: #EA3723;
  334. }
  335. .shuiyin{
  336. overflow: hidden;
  337. width: 260rpx;
  338. height: 280rpx;
  339. position: absolute;
  340. right: 10rpx;
  341. top: 30rpx;
  342. }
  343. .bg-img{
  344. width: 100vw;
  345. height: 420rpx;
  346. }
  347. .navbar-top{
  348. position: fixed;
  349. width: 100%;
  350. top: 0;
  351. z-index:99999;
  352. padding-top:var(--status-bar-height);
  353. transition: top .25s;
  354. .title{
  355. padding: 18.18rpx 0;
  356. }
  357. }
  358. .card{
  359. position: relative;
  360. margin: -240rpx 20rpx 0;
  361. border-radius: 20rpx;
  362. background-color: #FFFFFF;
  363. .info{
  364. padding: 20rpx 20rpx 0;
  365. display: flex;
  366. justify-content: space-between;
  367. .avatar{
  368. width: 100rpx;
  369. height: 100rpx;
  370. border-radius: 50%;
  371. }
  372. .nickname{
  373. font-weight: 800;
  374. color: #222222;
  375. font-size: 30rpx;
  376. margin-left: 20rpx;
  377. display: flex;
  378. align-items: center;
  379. justify-content: center;
  380. }
  381. }
  382. }
  383. .account{
  384. padding: 20rpx;
  385. color: #222222;
  386. margin: 20rpx;
  387. border-radius: 20rpx;
  388. background-color: #FFFFFF;
  389. .title{
  390. padding-left: 20rpx;
  391. font-weight: 800;
  392. font-size: 34rpx;
  393. color: #26272F;
  394. }
  395. .menu{
  396. display: flex;
  397. justify-content: space-around;
  398. view{
  399. padding-top: 20rpx;
  400. display: flex;
  401. flex-direction: column;
  402. justify-content: center;
  403. align-items: center;
  404. text:first-child{
  405. font-weight: 800;
  406. padding-bottom: 10rpx;
  407. font-size: 32rpx;
  408. color: #FF9447;
  409. }
  410. text:last-child{
  411. }
  412. }
  413. }
  414. }
  415. .exchange{
  416. border-radius: 20rpx;
  417. background-color: #FFFFFF;
  418. padding: 10rpx 10rpx 30rpx;
  419. margin: 20rpx;
  420. .top{
  421. text:first-child{
  422. font-size: 34rpx;
  423. font-weight: 800;
  424. color: #26272F;
  425. }
  426. text:last-child{
  427. padding-top: 10rpx;
  428. font-size: 26rpx;
  429. color: #999999;
  430. }
  431. }
  432. .menu-list{
  433. display: flex;
  434. justify-content: space-around;
  435. .item{
  436. margin-top: 20rpx;
  437. width: 31%;
  438. padding: 15rpx 0;
  439. border-radius: 16rpx;
  440. display: flex;
  441. justify-content: center;
  442. align-items: center;
  443. flex-direction: column;
  444. .title{
  445. font-weight: 800;
  446. margin-bottom: 10rpx;
  447. }
  448. image{
  449. margin-bottom: 10rpx;
  450. border-radius: 50%;
  451. padding: 15rpx;
  452. background-color: #FFFFFF;
  453. width: 70rpx;
  454. height: 70rpx;
  455. }
  456. }
  457. .item1{
  458. background-image: linear-gradient(to right,#F7F0E7,#E9CEB9);
  459. view{
  460. font-size: 26rpx;
  461. padding: 10rpx 50rpx;
  462. background-color: #FF9447;
  463. color: #FFFFFF;
  464. }
  465. }
  466. .item2{
  467. background-image: linear-gradient(to right,#E8F2FC,#C3D5ED);
  468. view{
  469. font-size: 26rpx;
  470. padding: 10rpx 20rpx;
  471. background-color: #4AB0FF;
  472. color: #FFFFFF;
  473. }
  474. }
  475. .item3{
  476. background-image: linear-gradient(to right,#F7E9E9,#EAC4C3);
  477. view{
  478. font-size: 26rpx;
  479. padding: 10rpx 20rpx;
  480. background-color: #CF4948;
  481. color: #FFFFFF;
  482. }
  483. }
  484. }
  485. }
  486. .consume{
  487. border-radius: 20rpx;
  488. background-color: #FFFFFF;
  489. padding: 10rpx 10rpx 30rpx;
  490. margin: 20rpx;
  491. .top{
  492. text:first-child{
  493. font-size: 34rpx;
  494. font-weight: 800;
  495. color: #26272F;
  496. }
  497. text:last-child{
  498. padding-top: 10rpx;
  499. font-size: 26rpx;
  500. color: #999999;
  501. }
  502. }
  503. }
  504. .top{
  505. display: flex;
  506. justify-content: space-between;
  507. }
  508. </style>