mine.vue 14 KB

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