my.vue 9.8 KB

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