You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

542 lines
13 KiB

6 months ago
  1. <template>
  2. <view class="container">
  3. <view class="user-section">
  4. <image class="bg" src="/static/img/user-bg.jpg"></image>
  5. <view class="user-info-box">
  6. <view class="portrait-box">
  7. <image class="portrait" :src="userInfo.portrait || '/static/img/missing-face.png'"></image>
  8. </view>
  9. <view class="info-box">
  10. <text class="username">{{userInfo.name || '游客'}}</text>
  11. <text class="usercode" @click="checklogin()">编号{{userInfo.usercode || '请登录'}}</text>
  12. </view>
  13. </view>
  14. </view>
  15. <view class="cover-container">
  16. <image class="arc" src="/static/img/arc.png"></image>
  17. <view class="tj-sction" v-if="showsh">
  18. <view class="tj-item" @click="tochongzhi()">
  19. <text class="num">{{personinfo.yue}}<text v-if="personinfo.djmoney" class="djmoney">冻结:{{personinfo.djmoney}}</text></text>
  20. <text>余额</text>
  21. </view>
  22. <view class="tj-item" @click="tocoupon()">
  23. <text class="num">{{personinfo.yhqnum}}</text>
  24. <text>优惠券</text>
  25. </view>
  26. <view class="tj-item" @click="tojifen()">
  27. <text class="num">{{personinfo.jifen}}</text>
  28. <text>积分</text>
  29. </view>
  30. </view>
  31. <view class="order-section">
  32. <view class="order-item" @click="navTo('/pages/orderlist/orderlist?state=0')" hover-class="common-hover" :hover-stay-time="50">
  33. <text class="yticon icon-shouye" style="color: #3883FA;"></text>
  34. <text>全部订单</text>
  35. </view>
  36. <view class="order-item" @click="navTo('/pages/orderlist/orderlist?state=1')" hover-class="common-hover" :hover-stay-time="50">
  37. <text class="yticon icon-daifukuan" style="color: #3883FA;"></text>
  38. <text>已确认</text>
  39. </view>
  40. <view class="order-item" @click="navTo('/pages/orderlist/orderlist?state=2')" hover-class="common-hover" :hover-stay-time="50">
  41. <text class="yticon icon-yishouhuo" style="color: #3883FA;"></text>
  42. <text>待确认</text>
  43. </view>
  44. <view class="order-item" @click="navTo('/pages/orderlist/orderlist?state=3')" hover-class="common-hover" :hover-stay-time="50">
  45. <text class="yticon icon-shouhoutuikuan" style="color: #3883FA;"></text>
  46. <text>已取消</text>
  47. </view>
  48. </view>
  49. <!-- 浏览历史 -->
  50. <view class="history-section icon">
  51. <view class="sec-header">
  52. <text class="yticon icon-lishijilu"></text>
  53. <text v-if="recordlist.length>0">浏览历史</text>
  54. <text v-if="recordlist.length==0" @click="tipnomore()">浏览历史</text>
  55. <view class="clean" @click="cleanall()" v-if="recordlist.length>0">清除历史</view>
  56. </view>
  57. <scroll-view scroll-x class="h-list">
  58. <image v-for="(item, index) in recordlist" :key="index" @click="navTo('/pages/product/product?cpid='+item.cpid)" :src="item.img" mode="aspectFill"></image>
  59. </scroll-view>
  60. <list-cell icon="icon-shoucang_xuanzhongzhuangtai" iconColor="#54b4ef" title="我的收藏" @eventClick="navTo('/pages/user/keep')"></list-cell>
  61. <view class="kf">
  62. <view class="kfleft">
  63. <image src="../../static/img/kefu.png"></image>
  64. </view>
  65. <view class="kfright">
  66. <button class="kfbt" open-type="contact" >联系客服</button>
  67. </view>
  68. </view>
  69. <list-cell icon="icon-shezhi1" v-if="userInfo.openid" iconColor="#e07472" title="退出" border="" @eventClick="logout()"></list-cell>
  70. <list-cell icon="icon-shezhi1" v-if="!userInfo.openid" iconColor="#e07472" title="登录" border="" @eventClick="checklogin()"></list-cell>
  71. </view>
  72. </view>
  73. </view>
  74. </template>
  75. <script>
  76. // 功能列表小封装
  77. import * as XLSX from '@/static/excel.js';
  78. import listCell from '@/components/mix-list-cell';
  79. let startY = 0, moveY = 0, pageAtTop = true;
  80. export default {
  81. components: {
  82. listCell
  83. },
  84. data(){
  85. return {
  86. coverTransform: 'translateY(0px)',
  87. coverTransition: '0s',
  88. moving: false,
  89. userInfo:[],
  90. recordlist:[],
  91. showsh:0,
  92. personinfo:[]
  93. }
  94. },
  95. onShow(){
  96. this.baseset();
  97. let getuserinfo=uni.getStorageSync('userinfo');
  98. //console.log(getuserinfo);
  99. if(getuserinfo!=''){
  100. this.getread_recordlsit(getuserinfo.uid);
  101. this.userInfo=getuserinfo;
  102. }
  103. this.userinfo();
  104. },
  105. onLoad(){
  106. },
  107. // #ifndef MP
  108. onNavigationBarButtonTap(e) {
  109. const index = e.index;
  110. // if (index === 0) {
  111. // this.navTo('/pages/set/set');
  112. // }else if(index === 1){
  113. // // #ifdef APP-PLUS
  114. // const pages = getCurrentPages();
  115. // const page = pages[pages.length - 1];
  116. // const currentWebview = page.$getAppWebview();
  117. // currentWebview.hideTitleNViewButtonRedDot({
  118. // index
  119. // });
  120. // // #endif
  121. // uni.navigateTo({
  122. // url: '/pages/notice/notice'
  123. // })
  124. // }
  125. },
  126. // #endif
  127. computed: {
  128. },
  129. methods: {
  130. async baseset() {
  131. let reinfo=await this.$api.baseset({action:'baseset'});
  132. this.showsh=reinfo.code;
  133. },
  134. async userinfo() {
  135. let getuserinfo=uni.getStorageSync('userinfo');
  136. let reinfo=await this.$api.userinfo({action:'userinfo',uid:getuserinfo.uid,aid:getuserinfo.aid});
  137. this.personinfo=reinfo.data;
  138. },
  139. //获取浏览列表
  140. async getread_recordlsit(uid) {
  141. let reinfo=await this.$api.getread_recordlsit({action:'getread_recordlsit',uid:uid});
  142. this.recordlist=reinfo.data;
  143. },
  144. //清空浏览列表
  145. async cleanrecord() {
  146. let reinfo=await this.$api.cleanrecord({action:'cleanrecord',uid:this.userInfo.uid});
  147. if(reinfo.code==1){
  148. this.getread_recordlsit()
  149. }
  150. uni.hideLoading();
  151. },
  152. //清空浏览历史
  153. cleanall(){
  154. let t=this;
  155. t.checklogin();
  156. uni.showModal({
  157. title: '温馨提示',
  158. content: '是否清空浏览历史记录?',
  159. success: function (res) {
  160. if (res.confirm) {
  161. uni.showLoading({
  162. title:'正在清除...'
  163. })
  164. t.cleanrecord()
  165. } else if (res.cancel) {
  166. //console.log('用户点击取消');
  167. }
  168. }
  169. });
  170. },
  171. tipnomore(){
  172. uni.showToast({
  173. title:'暂无浏览历史',icon:'none'
  174. })
  175. },
  176. navTo(url){
  177. let getuserinfo=uni.getStorageSync('userinfo');
  178. if(getuserinfo==''){
  179. // uni.navigateTo({
  180. // url:'/pages/user/checklogin'
  181. // })
  182. uni.navigateTo({
  183. url:'/pages/user/login'
  184. })
  185. }else{
  186. uni.navigateTo({
  187. url
  188. })
  189. }
  190. },
  191. //点击积分
  192. tojifen(){
  193. let getuserinfo=uni.getStorageSync('userinfo');
  194. if(getuserinfo==''){
  195. uni.navigateTo({
  196. url:'/pages/user/login'
  197. })
  198. }else{
  199. uni.navigateTo({
  200. url:'/pages/user/jifen'
  201. })
  202. }
  203. },
  204. //点击余额
  205. tochongzhi(){
  206. let getuserinfo=uni.getStorageSync('userinfo');
  207. if(getuserinfo==''){
  208. uni.navigateTo({
  209. url:'/pages/user/login'
  210. })
  211. }else{
  212. uni.navigateTo({
  213. url:'/pages/user/chongzhi?yue='+this.personinfo.yue
  214. })
  215. }
  216. },
  217. tocoupon(){
  218. let getuserinfo=uni.getStorageSync('userinfo');
  219. if(getuserinfo==''){
  220. uni.navigateTo({
  221. url:'/pages/user/login'
  222. })
  223. }else{
  224. uni.navigateTo({
  225. url:'/pages/coupon/coupon'
  226. })
  227. }
  228. },
  229. /**
  230. * 会员卡下拉和回弹
  231. * 1.关闭bounce避免ios端下拉冲突
  232. * 2.由于touchmove事件的缺陷以前做小程序就遇到比如20跳到40h5反而好很多下拉的时候会有掉帧的感觉
  233. * transition设置0.1秒延迟让css来过渡这段空窗期
  234. * 3.回弹效果可修改曲线值来调整效果推荐一个好用的bezier生成工具 http://cubic-bezier.com/
  235. */
  236. coverTouchstart(e){
  237. if(pageAtTop === false){
  238. return;
  239. }
  240. this.coverTransition = 'transform .1s linear';
  241. startY = e.touches[0].clientY;
  242. },
  243. coverTouchmove(e){
  244. moveY = e.touches[0].clientY;
  245. let moveDistance = moveY - startY;
  246. if(moveDistance < 0){
  247. this.moving = false;
  248. return;
  249. }
  250. this.moving = true;
  251. if(moveDistance >= 80 && moveDistance < 100){
  252. moveDistance = 80;
  253. }
  254. if(moveDistance > 0 && moveDistance <= 80){
  255. this.coverTransform = `translateY(${moveDistance}px)`;
  256. }
  257. },
  258. coverTouchend(){
  259. if(this.moving === false){
  260. return;
  261. }
  262. this.moving = false;
  263. this.coverTransition = 'transform 0.3s cubic-bezier(.21,1.93,.53,.64)';
  264. this.coverTransform = 'translateY(0px)';
  265. },
  266. checklogin(){
  267. let getuserinfo=uni.getStorageSync('userinfo');
  268. if(getuserinfo==''){
  269. // uni.navigateTo({
  270. // url:'/pages/user/checklogin'
  271. // })
  272. uni.navigateTo({
  273. url:'/pages/user/login'
  274. })
  275. }
  276. },
  277. logout(){
  278. uni.showModal({
  279. title: '温馨提示',
  280. content: '请问是否退出登录',
  281. success: function (res) {
  282. if (res.confirm) {
  283. uni.showToast({
  284. title:'已退出'
  285. })
  286. uni.clearStorage('userinfo');
  287. uni.reLaunch({
  288. url:'/pages/index/index'
  289. })
  290. } else if (res.cancel) {
  291. }
  292. }
  293. });
  294. }
  295. }
  296. }
  297. </script>
  298. <style lang='scss'>
  299. %flex-center {
  300. display:flex;
  301. flex-direction: column;
  302. justify-content: center;
  303. align-items: center;
  304. }
  305. %section {
  306. display:flex;
  307. justify-content: space-around;
  308. align-content: center;
  309. background: #fff;
  310. border-radius: 10upx;
  311. }
  312. .user-section{
  313. height: 520upx;
  314. padding: 100upx 30upx 0;
  315. position:relative;
  316. .bg{
  317. position:absolute;
  318. left: 0;
  319. top: 0;
  320. width: 100%;
  321. height: 100%;
  322. filter: blur(1px);
  323. opacity: .7;
  324. }
  325. }
  326. .user-info-box{
  327. height: 180upx;
  328. display:flex;
  329. align-items:center;
  330. position:relative;
  331. z-index: 1;
  332. .portrait{
  333. width: 130upx;
  334. height: 130upx;
  335. border:5upx solid #fff;
  336. border-radius: 50%;
  337. }
  338. .username{
  339. font-size: $font-lg + 6upx;
  340. color: $font-color-dark;
  341. margin-left: 20upx;
  342. }
  343. .usercode{
  344. padding: 8rpx;
  345. border-radius: 15rpx;
  346. background-color: #4399FC;
  347. color: #fff;
  348. font-size: 35rpx;
  349. position: relative;
  350. left: 20rpx;
  351. }
  352. }
  353. .vip-card-box{
  354. display:flex;
  355. flex-direction: column;
  356. color: #f7d680;
  357. height: 240upx;
  358. background: linear-gradient(left, rgba(0,0,0,.7), rgba(0,0,0,.8));
  359. border-radius: 16upx 16upx 0 0;
  360. overflow: hidden;
  361. position: relative;
  362. padding: 20upx 24upx;
  363. .card-bg{
  364. position:absolute;
  365. top: 20upx;
  366. right: 0;
  367. width: 380upx;
  368. height: 260upx;
  369. }
  370. .b-btn{
  371. position: absolute;
  372. right: 20upx;
  373. top: 16upx;
  374. width: 132upx;
  375. height: 40upx;
  376. text-align: center;
  377. line-height: 40upx;
  378. font-size: 22upx;
  379. color: #36343c;
  380. border-radius: 20px;
  381. background: linear-gradient(left, #f9e6af, #ffd465);
  382. z-index: 1;
  383. }
  384. .tit{
  385. font-size: $font-base+2upx;
  386. color: #f7d680;
  387. margin-bottom: 28upx;
  388. .yticon{
  389. color: #f6e5a3;
  390. margin-right: 16upx;
  391. font-size: $font-base+18upx;
  392. }
  393. }
  394. .e-b{
  395. font-size: $font-sm;
  396. color: #d8cba9;
  397. margin-top: 10upx;
  398. }
  399. }
  400. .cover-container{
  401. background: $page-color-base;
  402. margin-top: -150upx;
  403. padding: 0 30upx;
  404. position:relative;
  405. background: #f5f5f5;
  406. padding-bottom: 20upx;
  407. .arc{
  408. position:absolute;
  409. left: 0;
  410. top: -34upx;
  411. width: 100%;
  412. height: 36upx;
  413. }
  414. }
  415. .tj-sction{
  416. @extend %section;
  417. .tj-item{
  418. @extend %flex-center;
  419. flex-direction: column;
  420. height: 140upx;
  421. font-size: $font-sm;
  422. color: #75787d;
  423. }
  424. .num{
  425. font-size: $font-lg;
  426. color: $font-color-dark;
  427. margin-bottom: 8upx;
  428. }
  429. }
  430. .order-section{
  431. @extend %section;
  432. padding: 28upx 0;
  433. margin-top: 20upx;
  434. .order-item{
  435. @extend %flex-center;
  436. width: 120upx;
  437. height: 120upx;
  438. border-radius: 10upx;
  439. font-size: $font-sm;
  440. color: $font-color-dark;
  441. }
  442. .yticon{
  443. font-size: 48upx;
  444. margin-bottom: 18upx;
  445. color: #fa436a;
  446. }
  447. .icon-shouhoutuikuan{
  448. font-size:44upx;
  449. }
  450. }
  451. .history-section{
  452. padding: 30upx 0 0;
  453. margin-top: 20upx;
  454. background: #fff;
  455. border-radius:10upx;
  456. .sec-header{
  457. display:flex;
  458. align-items: center;
  459. font-size: $font-base;
  460. color: $font-color-dark;
  461. line-height: 40upx;
  462. margin-left: 30upx;
  463. .yticon{
  464. font-size: 44upx;
  465. color: #5eba8f;
  466. margin-right: 16upx;
  467. line-height: 40upx;
  468. }
  469. }
  470. .h-list{
  471. white-space: nowrap;
  472. padding: 30upx 30upx 0;
  473. image{
  474. display:inline-block;
  475. width: 160upx;
  476. height: 160upx;
  477. margin-right: 20upx;
  478. border-radius: 10upx;
  479. }
  480. }
  481. }
  482. .clean{
  483. position: absolute;
  484. right: 45upx;
  485. padding: 3upx 8upx;
  486. background-color: #DD524D;
  487. color: #fff;
  488. border-radius: 10upx;
  489. font-size: $font-base;
  490. }
  491. .kf{
  492. display: flex;
  493. padding: 20upx $page-row-spacing;
  494. line-height:60upx;
  495. position:relative;
  496. align-items:center;
  497. image{
  498. left: 90upx;
  499. width: 50upx;
  500. height: 50upx;
  501. }
  502. .kfright{
  503. width: 30%;
  504. }
  505. .kfbt{
  506. font-size: $font-base;
  507. background: none;
  508. position: relative;
  509. left: -35upx;
  510. color: $font-color-dark;
  511. }
  512. .kfbt::after {border: 0;}
  513. }
  514. /* 自定义样式,非组件 */
  515. .myitem{
  516. display: flex;
  517. align-items:center;
  518. padding: 20upx $page-row-spacing;
  519. image{
  520. left: 90upx;
  521. width: 40upx;
  522. height: 40upx;
  523. }
  524. .myitemright{
  525. width: 80%;
  526. font-size: $font-sm+2upx;
  527. color: $font-color-dark;
  528. margin-left: 15upx;
  529. margin-bottom: 10upx;
  530. }
  531. }
  532. </style>