my.vue 9.8 KB

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