my.vue 12 KB

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