my.vue 9.6 KB

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