my.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  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. <!-- 个人中心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 style="height: 300rpx;" v-if="userinfo.appletUserId">
  105. <view class="logout" @click="logout">退出登录</view>
  106. </view>
  107. </view>
  108. <ax-popup ref="filter" position="" maskType="black" maskEnable maskClose>
  109. <l-painter ref="painter" isCanvasToTempFilePath @success="path = $event">
  110. <l-painter-view css="position:relative;">
  111. <l-painter-image
  112. src="https://hyxhsh.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/XVsEVGuCCbNv4aee36cc2f76e7050f62ebad3080ad88.jpg/1.jpg"
  113. css="width:600rpx; height: 1000rpx" />
  114. <l-painter-qrcode :text="'https://cd.admin.zswlgz.com/v2/?frimId=' + userinfo.firmId"
  115. css="width:260rpx; height: 260rpx;position: absolute;top:27%;left:29%" />
  116. <l-painter-text
  117. css="position: absolute;top:594rpx;left:50%;transform:translateX(-50%);color:#216ff7;font-size:22rpx;width:60%;text-align:center;"
  118. align="center" :text="userinfo.firmName ? userinfo.firmName : '默认企业'">
  119. </l-painter-text>
  120. <l-painter-text css="position: absolute;top:86%;left:37%;color:#ffffff;font-size:24rpx"
  121. :text="userinfo.nickName ? userinfo.nickName : '匿名用户'">
  122. </l-painter-text>
  123. </l-painter-view>
  124. </l-painter>
  125. <view class="enterprise-tips" @click="savePainter">保存海报</view>
  126. </ax-popup>
  127. <!-- 导航栏 -->
  128. <view style="position: fixed;width: 100%;bottom:100rpx;z-index: 100;">
  129. <app-navigation active="my"></app-navigation>
  130. </view>
  131. </ax-body>
  132. </template>
  133. <script>
  134. import $config from '@/static/js/config.js';
  135. export default {
  136. data() {
  137. return {
  138. userinfo: {},
  139. banners: [],
  140. }
  141. },
  142. onShow() {
  143. this.getMyAccount()
  144. },
  145. mounted() {
  146. this.getBanners()
  147. },
  148. methods: {
  149. openFilter() {
  150. this.$refs.filter.open();
  151. },
  152. // 版头加载完成
  153. bannerLoadCompleted() {
  154. this.setListHeight();
  155. },
  156. showImg(img) {
  157. return this.$config.url.request + img
  158. },
  159. getBanners() {
  160. this.$api.base("get", "/applet/v1/homePage/getBannerList/2", {}, {}).then(res => {
  161. this.banners = res.data
  162. })
  163. },
  164. savePainter() {
  165. this.$refs.painter.canvasToTempFilePathSync({
  166. fileType: "png",
  167. // 如果返回的是base64是无法使用 saveImageToPhotosAlbum,需要设置 pathType为url
  168. pathType: 'url',
  169. quality: 1,
  170. success: (res) => {
  171. console.log(res.tempFilePath);
  172. uni.showShareImageMenu({
  173. path: res.tempFilePath,
  174. success: () => {
  175. console.log('分享成功');
  176. },
  177. fail: (err) => {
  178. console.error('分享失败', err);
  179. }
  180. });
  181. },
  182. });
  183. },
  184. refund() {
  185. this.$app.popup.confirm("退款按照购券记录进行逐笔退款,可能产生多笔退款到账记录,请注意查收。", "退款说明").then(confirm => {
  186. if (confirm) {
  187. this.$api.base("put", '/applet/v1/wft/order/refundOrder', {}).then(res => {
  188. if (res.code == '00000') {
  189. this.$app.popup.alert(res.data).then(() => {
  190. this.getMyAccount()
  191. });
  192. } else {
  193. this.$app.popup.alert(res.data);
  194. }
  195. });
  196. }
  197. });
  198. },
  199. openPrivacyContract() {
  200. uni.openPrivacyContract();
  201. },
  202. // 打开客服
  203. customerService() {
  204. const cs = this.$config.customerService;
  205. this.$app.act.customerService(cs.id, cs.url).catch(err => {
  206. console.log(err);
  207. this.$app.popup.alert('客服中心失联啦,请联系管理员!');
  208. });
  209. },
  210. getMyAccount() {
  211. // let channelUrl = 'http://192.168.110.241:9120/zs/channel/admin/'
  212. let channelUrl = 'https://channel-api.zonelife.cn/zs/channel/admin/'
  213. this.$api.base("get", "/applet/v1/user/getUserInfo", {}, {
  214. error: false
  215. }).then(res => {
  216. console.log(res);
  217. this.userinfo = res.data
  218. this.$app.storage.set('USER_INFO', res.data);
  219. // 识别用户是否通过分销码进入小程序
  220. if (uni.getStorageSync('ADMIN_USERID')) {
  221. uni.request({
  222. url: channelUrl + 'ums/umsAdminUser/distributionBindUser',
  223. method: 'POST',
  224. header: {
  225. 'content-type': 'application/json'
  226. },
  227. data: {
  228. userId: uni.getStorageSync('USER_INFO').id,
  229. adminUserId: parseInt(uni.getStorageSync('ADMIN_USERID')),
  230. },
  231. success: (res) => {
  232. setTimeout(() => {
  233. this.$app.storage.remove('ADMIN_USERID')
  234. }, 500)
  235. },
  236. fail(err) {
  237. console.log(err, '----错误信息');
  238. }
  239. });
  240. }
  241. })
  242. },
  243. get_firmId() {
  244. if (this.$app.storage.get('FRIM_ID')) {
  245. this.$api.base("post", "/userApi/add-firm-user?firmId=" + parseInt(this.$app.storage.get(
  246. 'FRIM_ID')), {}, {
  247. error: false
  248. }).then(res => {
  249. this.$app.popup.alert(res.msg);
  250. setTimeout(() => {
  251. this.$app.storage.remove('FRIM_ID')
  252. }, 500)
  253. }).catch(err => {
  254. setTimeout(() => {
  255. this.$app.storage.remove('FRIM_ID')
  256. }, 500)
  257. })
  258. }
  259. },
  260. onGetPhoneNumber(e) {
  261. uni.login({
  262. provider: 'weixin',
  263. success: (result) => {
  264. console.log(result, '微信登录');
  265. if (result.code) {
  266. if (e.detail.code) {
  267. this.$api.base("post", '/api/v1/auth/wx/miniapp/phone-code-login', {
  268. code: result.code,
  269. phoneCode: e.detail.code
  270. }).then(res => {
  271. console.log(res);
  272. uni.setStorageSync($config.keyname.accessToken, res?.data?.accessToken);
  273. uni.setStorageSync($config.keyname.refreshToken, res?.data?.refreshToken);
  274. this.$app.storage.set('USER_INFO', res.data);
  275. this.getMyAccount();
  276. this.get_firmId()
  277. });
  278. }
  279. }
  280. },
  281. fail: (error) => { }
  282. })
  283. },
  284. logout() {
  285. this.$app.popup.confirm("确认退出登录?").then(confirm => {
  286. if (confirm) {
  287. this.$api.base('delete', '/api/v1/auth/logout').then(() => {
  288. uni.removeStorageSync($config.keyname.accessToken);
  289. uni.removeStorageSync($config.keyname.refreshToken);
  290. this.$app.storage.remove('USER_INFO');
  291. // 跳转首页
  292. uni.reLaunch({
  293. url: '/pages/index/index'
  294. });
  295. });
  296. }
  297. });
  298. }
  299. }
  300. }
  301. </script>
  302. <style scoped>
  303. @import url("my.css");
  304. .refund_btn {
  305. position: absolute;
  306. font-size: 14px;
  307. color: #fff;
  308. background-color: #3EB6F8;
  309. padding: 2px 8px;
  310. border-radius: 10px 0 0 10px;
  311. bottom: 5px;
  312. right: 0;
  313. z-index: 99;
  314. }
  315. </style>