mine.vue 14 KB

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