mine.vue 13 KB

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