my.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  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.firmInfoName">{{userinfo.firmInfoName}}</view>
  17. </view>
  18. <view class="user-phone" v-if="userinfo.phone">{{userinfo.phone?userinfo.phone:'未获取手机'}}</view>
  19. <button v-if="!userinfo.phone" @getphonenumber="onGetPhoneNumber" open-type="getPhoneNumber"
  20. class="get-phone-number">授权并登录</button>
  21. </view>
  22. </view>
  23. <!-- <image src="@/static/img/seting.svg" class="seting-icon"></image> -->
  24. </view>
  25. <!-- 统计卡 -->
  26. <view class="app-flex c-between">
  27. <view class="sta-card">
  28. <view class="value">{{userinfo.integralNum}}</view>
  29. <view class="name">我的积分</view>
  30. <image src="@/static/img/my-sta-bg01.png" mode="heightFix" class="bg"></image>
  31. </view>
  32. <view class="sta-card">
  33. <view class="value">{{userinfo.params.balance}}</view>
  34. <view class="name">可抵扣余量</view>
  35. <image src="@/static/img/my-sta-bg03.png" mode="heightFix" class="bg"></image>
  36. <view class="refund_btn" @click="refund">
  37. 退还
  38. </view>
  39. </view>
  40. </view>
  41. <view @click="$app.url.goto('/pages/coupon-buy/coupon-buy')" class="buy">购买充电券</view>
  42. <!-- 常用工具 -->
  43. <view class="card">
  44. <view class="card-title">常用工具</view>
  45. <view class="act-wrap">
  46. <view class="act-item" @click="$app.url.goto('/pages/recharge-log/recharge-log')">
  47. <image src="@/static/img/my-icon01.svg" class="icon"></image>
  48. <view class="name">购券记录</view>
  49. </view>
  50. <view class="act-item" @click="$app.url.goto('/pages/order/order')">
  51. <image src="@/static/img/my-icon02.svg" class="icon"></image>
  52. <view class="name">我的订单</view>
  53. </view>
  54. <view class="act-item" @click="$app.url.goto('/pages/feedback/feedback')">
  55. <image src="@/static/img/my-icon03.svg" class="icon"></image>
  56. <view class="name">意见反馈</view>
  57. </view>
  58. <view class="act-item" @click="customerService()">
  59. <image src="@/static/img/my-icon04.svg" class="icon"></image>
  60. <view class="name">在线客服</view>
  61. </view>
  62. </view>
  63. </view>
  64. <!-- 更多功能 -->
  65. <view class="card">
  66. <view class="card-title">更多功能</view>
  67. <view class="act-wrap">
  68. <!-- <view class="act-item about">
  69. <image src="@/static/img/logo-small.png" class="icon"></image>
  70. <view class="name">关于我们</view>
  71. </view> -->
  72. <view class="act-item" @click="openPrivacyContract">
  73. <image src="@/static/img/my-icon05.svg" class="icon"></image>
  74. <view class="name">隐私条例</view>
  75. </view>
  76. <view class="act-item" @click="openFilter()" v-if="userinfo.firmType==1">
  77. <image src="@/static/img/my-icon06.svg" class="icon"></image>
  78. <view class="name">邀请员工</view>
  79. </view>
  80. </view>
  81. </view>
  82. </view>
  83. <ax-popup ref="filter" position="" maskType="black" maskEnable maskClose>
  84. <view class="playbil-box" @click="editPlaybil">
  85. <image class="playbil-bg" :src="playbil_img" mode="widthFix"></image>
  86. <image class="playbil-qrcode" :src="qrCode" mode=""></image>
  87. <view class="enterprise-name">
  88. 中数未来控股(深圳)有限责任公司
  89. </view>
  90. <view class="enterprise-user">{{userinfo.nickName?userinfo.nickName:'匿名用户'}}</view>
  91. <view class="enterprise-tips">*点击图片进行分享或保存</view>
  92. </view>
  93. </ax-popup>
  94. <r-canvas ref="rCanvas"></r-canvas>
  95. <!-- 导航栏 -->
  96. <app-navigation active="my"></app-navigation>
  97. </ax-body>
  98. </template>
  99. <script>
  100. import rCanvas from "@/components/r-canvas/r-canvas.vue"
  101. import $config from '@/static/js/config.js';
  102. export default {
  103. data() {
  104. return {
  105. userinfo: {},
  106. playbil_img: 'https://hyxhsh.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/XVsEVGuCCbNv4aee36cc2f76e7050f62ebad3080ad88.jpg/1.jpg',
  107. qrCode: null,
  108. }
  109. },
  110. onShow() {
  111. this.getMyAccount()
  112. },
  113. mounted() {},
  114. methods: {
  115. openFilter() {
  116. this.$refs.filter.open();
  117. this.get_qrCode()
  118. },
  119. get_qrCode() {
  120. uni.showLoading()
  121. uni.request({
  122. url: $config.url.request + '/userApi/get-invite-qr',
  123. method: 'GET',
  124. responseType: 'arraybuffer',
  125. header: {
  126. 'content-type': 'application/json',
  127. 'token': uni.getStorageSync($config.keyname.userToken)
  128. },
  129. data: {},
  130. success: (res) => {
  131. uni.hideLoading()
  132. const arrayBuffer = res.data;
  133. const base64 = wx.arrayBufferToBase64(arrayBuffer);
  134. this.qrCode = 'data:image/png;base64,' + base64;
  135. },
  136. fail(err) {
  137. uni.showToast({
  138. icon: "error",
  139. title: '获取二维码失败' + err
  140. })
  141. }
  142. });
  143. },
  144. // 操作图片
  145. editPlaybil() {
  146. // console.log(this.$refs.filter);
  147. this.get_downloadImg()
  148. },
  149. async get_downloadImg() {
  150. uni.showLoading()
  151. this.$nextTick(async () => {
  152. await this.$refs.rCanvas.init({
  153. canvas_id: "rCanvas"
  154. })
  155. await this.$refs.rCanvas.setCanvasWidth(300)
  156. await this.$refs.rCanvas.setCanvasHeight(515)
  157. // 背景卡片
  158. await this.$refs.rCanvas.drawImage({
  159. url: this.playbil_img,
  160. x: 0,
  161. y: 30,
  162. w: 300,
  163. h: 515
  164. }).catch(err_msg => {
  165. uni.showToast({
  166. title: err_msg,
  167. icon: "none"
  168. })
  169. })
  170. // 二维码
  171. await this.$refs.rCanvas.drawImage({
  172. url: this.qrCode,
  173. x: 85,
  174. y: 176,
  175. w: 130,
  176. h: 130
  177. }).catch(err_msg => {
  178. uni.showToast({
  179. title: err_msg,
  180. icon: "none"
  181. })
  182. })
  183. //文字
  184. await this.$refs.rCanvas.drawText({
  185. text: '中数未来控股(深圳)有限责任公司',
  186. max_width: 0,
  187. x: 56,
  188. y: 348,
  189. font_color: "#216ff7",
  190. font_size: 10
  191. }).catch(err_msg => {
  192. uni.showToast({
  193. title: err_msg,
  194. icon: "none"
  195. })
  196. })
  197. await this.$refs.rCanvas.drawText({
  198. text: this.userinfo.nickName ? userinfo.nickName : '匿名用户',
  199. max_width: 0,
  200. x: 122,
  201. y: 486,
  202. font_color: "#ffffff",
  203. font_size: 12
  204. }).catch(err_msg => {
  205. uni.showToast({
  206. title: err_msg,
  207. icon: "none"
  208. })
  209. })
  210. // 生成海报
  211. await this.$refs.rCanvas.draw((res) => {
  212. //res.tempFilePath:生成成功,返回base64图片
  213. uni.hideLoading()
  214. uni.showShareImageMenu({
  215. path: res.tempFilePath,
  216. success: (res) => console.log('分享成功', res),
  217. fail: (err) => console.error('分享失败', err),
  218. });
  219. // this.$refs.rCanvas.saveImage(res.tempFilePath)
  220. })
  221. })
  222. },
  223. refund() {
  224. this.$app.popup.confirm("退款按照购券记录进行逐笔退款,可能产生多笔退款到账记录,请注意查收。", "退款说明").then(confirm => {
  225. if (confirm) {
  226. this.$api.base("post", '/orderApi/refund', {}).then(res => {
  227. if (res.code == 0) {
  228. this.$app.popup.alert('退款成功!').then(() => {
  229. this.getMyAccount()
  230. });
  231. } else {
  232. this.$app.popup.alert(res.msg);
  233. }
  234. });
  235. }
  236. });;
  237. },
  238. openPrivacyContract() {
  239. uni.openPrivacyContract();
  240. },
  241. // 打开客服
  242. customerService() {
  243. const cs = this.$config.customerService;
  244. this.$app.act.customerService(cs.id, cs.url).catch(err => {
  245. console.log(err);
  246. this.$app.popup.alert('客服中心失联啦,请联系管理员!');
  247. });
  248. },
  249. getMyAccount() {
  250. // let channelUrl = 'http://192.168.110.241:9120/zs/channel/admin/'
  251. let channelUrl='https://channel-api.zonelife.cn/zs/channel/admin/'
  252. this.$api.base("post", "/userApi/getUserAccount", {}, {error:false}).then(res => {
  253. this.userinfo = res.accountInfo
  254. this.$app.storage.set('USER_INFO', res.accountInfo);
  255. // 识别用户是否通过分销码进入小程序
  256. if (uni.getStorageSync('ADMIN_USERID')) {
  257. uni.request({
  258. url: channelUrl + 'ums/umsAdminUser/distributionBindUser',
  259. method: 'POST',
  260. header: {
  261. 'content-type': 'application/json'
  262. },
  263. data: {
  264. userId: uni.getStorageSync('USER_INFO').id,
  265. adminUserId: parseInt(uni.getStorageSync('ADMIN_USERID')),
  266. },
  267. success: (res) => {
  268. setTimeout(()=>{
  269. this.$app.storage.remove('ADMIN_USERID')
  270. },500)
  271. },
  272. fail(err) {
  273. console.log(err, '----错误信息');
  274. }
  275. });
  276. }
  277. })
  278. },
  279. get_firmId() {
  280. if(this.$app.storage.get('FRIM_ID')){
  281. this.$api.base("post", "/userApi/add-firm-user?firmId=" + parseInt(this.$app.storage.get('FRIM_ID')), {}, {
  282. error: false
  283. }).then(res => {
  284. this.$app.popup.alert(res.msg);
  285. setTimeout(() => {
  286. this.$app.storage.remove('FRIM_ID')
  287. }, 500)
  288. console.log(res, '----企业用户通过扫码进入');
  289. }).catch(err => {
  290. setTimeout(() => {
  291. this.$app.storage.remove('FRIM_ID')
  292. }, 500)
  293. })
  294. }
  295. },
  296. onGetPhoneNumber(e) {
  297. if (e.detail.code) {
  298. this.$api.base("post", '/userApi/getPhone', {
  299. code: e.detail.code
  300. }).then(res => {
  301. this.$app.storage.set('USER_INFO', res.userInfo);
  302. this.getMyAccount();
  303. this.get_firmId()
  304. });
  305. }
  306. },
  307. }
  308. }
  309. </script>
  310. <style scoped>
  311. @import url("my.css");
  312. .refund_btn {
  313. position: absolute;
  314. font-size: 14px;
  315. color: #fff;
  316. background-color: #3EB6F8;
  317. padding: 2px 8px;
  318. border-radius: 10px 0 0 10px;
  319. bottom: 5px;
  320. right: 0;
  321. z-index: 99;
  322. }
  323. </style>