my.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. <template>
  2. <ax-body hide-indicator-area>
  3. <template #title></template>
  4. <view class="page-background">
  5. <image src="@/static/img/my-bg.svg" mode="widthFix"></image>
  6. </view>
  7. <!-- 主内容 -->
  8. <view class="main">
  9. <!-- 用户信息 -->
  10. <view class="app-flex c-between user-card">
  11. <view class="app-flex middle">
  12. <image src="@/static/img/user-avatar.svg" class="user-avatar"></image>
  13. <view>
  14. <view class="user-name">
  15. <view class="user-name-text">{{ userinfo.nickName ? userinfo.nickName : '匿名' }}</view>
  16. <view class="enterprise-name-card" v-if="userinfo.firmName">{{ userinfo.firmName }}
  17. </view>
  18. </view>
  19. <view class="user-phone" v-if="userinfo.appletUserId">{{ userinfo.phone ? userinfo.phone :
  20. '未获取手机号' }}
  21. </view>
  22. <button v-if="!userinfo.appletUserId" @getphonenumber="onGetPhoneNumber"
  23. open-type="getPhoneNumber" class="get-phone-number">授权并登录</button>
  24. </view>
  25. </view>
  26. <view class="seting-icon-box" @click="$app.url.goto('/subPackages/coupon/coupons/coupons')">
  27. <image class="img-icon"
  28. src="https://national-motion.oss-cn-beijing.aliyuncs.com/20251230/d76e9bad8597403c9816d481aafd88d3.png">
  29. </image>
  30. <view class="tips-text">优惠券</view>
  31. </view>
  32. </view>
  33. <!-- 统计卡 -->
  34. <view class="statistics-card">
  35. <view class="statistics-title">我的钱包</view>
  36. <view class="statistics-dataInfo">
  37. <view class="dataInfo-left">
  38. <view class="left-text">我的积分</view>
  39. <view class="left-number">{{ userinfo.integral }}</view>
  40. </view>
  41. <view class="dataInfo-line"></view>
  42. <view class="dataInfo-left">
  43. <view class="left-text">可抵扣余量</view>
  44. <view class="left-number">{{ userinfo.accountBalance }}</view>
  45. <view class="left-refund-btn" @click="refund">
  46. 退还
  47. </view>
  48. </view>
  49. </view>
  50. <view @click="$app.url.goto('/subPackages/coupon/coupon-buy/coupon-buy')" class="buy">购买充电券</view>
  51. </view>
  52. <!-- 我的车辆 -->
  53. <view class="card vehicle-card">
  54. <view class="vehicle-card-content">
  55. <view class="vehicle-left">
  56. <view class="card-title" style="padding:0;">我的车辆</view>
  57. <!-- 未绑定车辆 -->
  58. <view class="vehicle-empty" v-if="carList.length === 0" @click="goAddVehicle">
  59. <view class="vehicle-add-btn">
  60. <text class="vehicle-add-icon">+</text>
  61. </view>
  62. <view class="vehicle-add-text">添加车辆,享更多权益</view>
  63. </view>
  64. <!-- 已绑定车辆 -->
  65. <view class="vehicle-bound" v-else>
  66. <view class="vehicle-plate">{{ currentCar ? currentCar.licensePlate : carList[0].licensePlate }}</view>
  67. <view class="vehicle-manage-btn" @click="goManageVehicle">管理 <text class="vehicle-manage-arrow">></text></view>
  68. </view>
  69. </view>
  70. <image class="vehicle-car-img" src="https://national-motion.oss-cn-beijing.aliyuncs.com/20260318/9629c91c6a314e7f9e67af61ae14f2bd.png" mode="aspectFit"></image>
  71. </view>
  72. </view>
  73. <!-- 个人中心banner -->
  74. <swiper class="banner" style="margin-top: 20rpx" v-if="banners.length > 0" autoplay="true" circular>
  75. <swiper-item v-for="(item, index) in banners" :key="index" @click="$app.url.goto(item.jumpPage)">
  76. <view class="swiper-item">
  77. <image @load="bannerLoadCompleted()" :src="item.picture" class="swiper-item-image"
  78. mode="widthFix">
  79. </image>
  80. </view>
  81. </swiper-item>
  82. </swiper>
  83. <!-- 常用工具 -->
  84. <view class="card">
  85. <view class="card-title">常用工具</view>
  86. <view class="act-wrap">
  87. <view class="act-item" @click="$app.url.goto('/subPackages/coupon/recharge-log/recharge-log')">
  88. <image src="@/static/img/my-icon01.svg" class="icon"></image>
  89. <view class="name">购券记录</view>
  90. </view>
  91. <view class="act-item" @click="$app.url.goto('/subPackages/order/order/order')">
  92. <image src="@/static/img/my-icon02.svg" class="icon"></image>
  93. <view class="name">我的订单</view>
  94. </view>
  95. <view class="act-item" @click="$app.url.goto('/subPackages/other/feedback/feedback')">
  96. <image src="@/static/img/my-icon03.svg" class="icon"></image>
  97. <view class="name">意见反馈</view>
  98. </view>
  99. <view class="act-item" @click="customerService()">
  100. <image src="@/static/img/my-icon04.svg" class="icon"></image>
  101. <view class="name">在线客服</view>
  102. </view>
  103. </view>
  104. </view>
  105. <!-- 更多功能 -->
  106. <view class="card">
  107. <view class="card-title">更多功能</view>
  108. <view class="act-wrap">
  109. <!-- <view class="act-item about">
  110. <image src="@/static/img/logo-small.png" class="icon"></image>
  111. <view class="name">关于我们</view>
  112. </view> -->
  113. <view class="act-item" @click="openPrivacyContract">
  114. <image src="@/static/img/my-icon05.svg" class="icon"></image>
  115. <view class="name">隐私条例</view>
  116. </view>
  117. <!-- firmUserType===1管理员,2普通用户 -->
  118. <!-- v-if="userinfo.firmId && userinfo.firmUserType === 1" -->
  119. <view class="act-item" @click="openFilter()" v-if="userinfo.firmId && userinfo.firmUserType === 1">
  120. <image src="@/static/img/my-icon06.svg" class="icon"></image>
  121. <view class="name">邀请员工</view>
  122. </view>
  123. </view>
  124. </view>
  125. <view style="height: 300rpx;" v-if="userinfo.appletUserId">
  126. <view class="logout" @click="logout">退出登录</view>
  127. </view>
  128. </view>
  129. <ax-popup ref="filter" position="" maskType="black" maskEnable maskClose>
  130. <l-painter ref="painter" isCanvasToTempFilePath @success="path = $event">
  131. <l-painter-view css="position:relative;">
  132. <l-painter-image
  133. src="https://hyxhsh.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/XVsEVGuCCbNv4aee36cc2f76e7050f62ebad3080ad88.jpg/1.jpg"
  134. css="width:600rpx; height: 1000rpx" />
  135. <l-painter-qrcode :text="'https://cd.admin.zswlgz.com/v2/?frimId=' + userinfo.firmId"
  136. css="width:260rpx; height: 260rpx;position: absolute;top:27%;left:29%" />
  137. <l-painter-text
  138. css="position: absolute;top:594rpx;left:50%;transform:translateX(-50%);color:#216ff7;font-size:22rpx;width:60%;text-align:center;"
  139. align="center" :text="userinfo.firmName ? userinfo.firmName : '默认企业'">
  140. </l-painter-text>
  141. <l-painter-text css="position: absolute;top:86%;left:37%;color:#ffffff;font-size:24rpx"
  142. :text="userinfo.nickName ? userinfo.nickName : '匿名用户'">
  143. </l-painter-text>
  144. </l-painter-view>
  145. </l-painter>
  146. <view class="enterprise-tips" @click="savePainter">保存海报</view>
  147. </ax-popup>
  148. <!-- 导航栏 -->
  149. <view style="position: fixed;width: 100%;bottom:100rpx;z-index: 100;">
  150. <app-navigation active="my"></app-navigation>
  151. </view>
  152. </ax-body>
  153. </template>
  154. <script>
  155. import $config from '@/static/js/config.js';
  156. export default {
  157. data() {
  158. return {
  159. userinfo: {},
  160. banners: [],
  161. carList: [],
  162. currentCar: null,
  163. }
  164. },
  165. onShow() {
  166. this.getMyAccount()
  167. this.getCarList()
  168. },
  169. mounted() {
  170. this.getBanners()
  171. },
  172. methods: {
  173. openFilter() {
  174. this.$refs.filter.open();
  175. },
  176. // 版头加载完成
  177. bannerLoadCompleted() {
  178. this.setListHeight();
  179. },
  180. showImg(img) {
  181. return this.$config.url.request + img
  182. },
  183. getBanners() {
  184. this.$api.base("get", "/applet/v1/homePage/getBannerList/2", {}, {}).then(res => {
  185. this.banners = res.data
  186. })
  187. },
  188. savePainter() {
  189. this.$refs.painter.canvasToTempFilePathSync({
  190. fileType: "png",
  191. // 如果返回的是base64是无法使用 saveImageToPhotosAlbum,需要设置 pathType为url
  192. pathType: 'url',
  193. quality: 1,
  194. success: (res) => {
  195. console.log(res.tempFilePath);
  196. uni.showShareImageMenu({
  197. path: res.tempFilePath,
  198. success: () => {
  199. console.log('分享成功');
  200. },
  201. fail: (err) => {
  202. console.error('分享失败', err);
  203. }
  204. });
  205. },
  206. });
  207. },
  208. goAddVehicle() {
  209. this.$app.url.goto('/subPackages/other/addLicensePlates/addLicensePlates');
  210. },
  211. goManageVehicle() {
  212. this.$app.url.goto('/subPackages/other/addLicensePlates/addLicensePlates');
  213. },
  214. getCarList() {
  215. this.$api.base('get', '/applet/v1/vehicle/default', {}, { error: false }).then(res => {
  216. if (res && res.data) {
  217. // 接口返回的是默认车辆对象
  218. this.currentCar = res.data;
  219. this.carList = [res.data];
  220. } else {
  221. this.currentCar = null;
  222. this.carList = [];
  223. }
  224. }).catch(() => {
  225. this.currentCar = null;
  226. this.carList = [];
  227. });
  228. },
  229. refund() {
  230. this.$app.popup.confirm("退款按照购券记录进行逐笔退款,可能产生多笔退款到账记录,请注意查收。", "退款说明").then(confirm => {
  231. if (confirm) {
  232. this.$api.base("put", '/applet/v1/wft/order/refundOrder', {}).then(res => {
  233. if (res.code == '00000') {
  234. this.$app.popup.alert(res.data).then(() => {
  235. this.getMyAccount()
  236. });
  237. } else {
  238. this.$app.popup.alert(res.data);
  239. }
  240. });
  241. }
  242. });
  243. },
  244. openPrivacyContract() {
  245. uni.openPrivacyContract();
  246. },
  247. // 打开客服
  248. customerService() {
  249. const cs = this.$config.customerService;
  250. this.$app.act.customerService(cs.id, cs.url).catch(err => {
  251. console.log(err);
  252. this.$app.popup.alert('客服中心失联啦,请联系管理员!');
  253. });
  254. },
  255. getMyAccount() {
  256. // let channelUrl = 'http://192.168.110.241:9120/zs/channel/admin/'
  257. let channelUrl = 'https://channel-api.zonelife.cn/zs/channel/admin/'
  258. this.$api.base("get", "/applet/v1/user/getUserInfo", {}, {
  259. error: false
  260. }).then(res => {
  261. console.log(res);
  262. this.userinfo = res.data
  263. this.$app.storage.set('USER_INFO', res.data);
  264. // 识别用户是否通过分销码进入小程序
  265. if (uni.getStorageSync('ADMIN_USERID')) {
  266. uni.request({
  267. url: channelUrl + 'ums/umsAdminUser/distributionBindUser',
  268. method: 'POST',
  269. header: {
  270. 'content-type': 'application/json'
  271. },
  272. data: {
  273. userId: uni.getStorageSync('USER_INFO').id,
  274. adminUserId: parseInt(uni.getStorageSync('ADMIN_USERID')),
  275. },
  276. success: (res) => {
  277. setTimeout(() => {
  278. this.$app.storage.remove('ADMIN_USERID')
  279. }, 500)
  280. },
  281. fail(err) {
  282. console.log(err, '----错误信息');
  283. }
  284. });
  285. }
  286. })
  287. },
  288. get_firmId() {
  289. if (this.$app.storage.get('FRIM_ID')) {
  290. this.$api.base("post", "/userApi/add-firm-user?firmId=" + parseInt(this.$app.storage.get(
  291. 'FRIM_ID')), {}, {
  292. error: false
  293. }).then(res => {
  294. this.$app.popup.alert(res.msg);
  295. setTimeout(() => {
  296. this.$app.storage.remove('FRIM_ID')
  297. }, 500)
  298. }).catch(err => {
  299. setTimeout(() => {
  300. this.$app.storage.remove('FRIM_ID')
  301. }, 500)
  302. })
  303. }
  304. },
  305. onGetPhoneNumber(e) {
  306. uni.login({
  307. provider: 'weixin',
  308. success: (result) => {
  309. console.log(result, '微信登录');
  310. if (result.code) {
  311. if (e.detail.code) {
  312. this.$api.base("post", '/api/v1/auth/wx/miniapp/phone-code-login', {
  313. code: result.code,
  314. phoneCode: e.detail.code
  315. }).then(res => {
  316. console.log(res);
  317. uni.setStorageSync($config.keyname.accessToken, res?.data?.accessToken);
  318. uni.setStorageSync($config.keyname.refreshToken, res?.data?.refreshToken);
  319. this.$app.storage.set('USER_INFO', res.data);
  320. this.getMyAccount();
  321. this.get_firmId()
  322. });
  323. }
  324. }
  325. },
  326. fail: (error) => { }
  327. })
  328. },
  329. logout() {
  330. this.$app.popup.confirm("确认退出登录?").then(confirm => {
  331. if (confirm) {
  332. this.$api.base('delete', '/api/v1/auth/logout').then(() => {
  333. uni.removeStorageSync($config.keyname.accessToken);
  334. uni.removeStorageSync($config.keyname.refreshToken);
  335. this.$app.storage.remove('USER_INFO');
  336. // 跳转首页
  337. uni.reLaunch({
  338. url: '/pages/index/index'
  339. });
  340. });
  341. }
  342. });
  343. }
  344. }
  345. }
  346. </script>
  347. <style scoped>
  348. @import url("my.css");
  349. .refund_btn {
  350. position: absolute;
  351. font-size: 14px;
  352. color: #fff;
  353. background-color: #3EB6F8;
  354. padding: 2px 8px;
  355. border-radius: 10px 0 0 10px;
  356. bottom: 5px;
  357. right: 0;
  358. z-index: 99;
  359. }
  360. </style>