bindAliAcc.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <view class="container">
  3. <u-navbar leftIconColor="#fff" titleStyle="color:#fff;fontSize:36rpx;" :autoBack="true" bgColor="#2C6FF3"
  4. :placeholder="true" title="账号绑定">
  5. </u-navbar>
  6. <view class="content flex flex-direction justify-between" :style="{height:fullHeight}">
  7. <view class="top flex flex-direction align-center">
  8. <view class="img">
  9. <u-image width="400rpx" height="400rpx"
  10. src="https://cdn.ossfile.mxrvending.com/assets/xy_merc_mini/images/alipayUid.png"
  11. mode="widthFix" :lazy-load="true">
  12. </u-image>
  13. </view>
  14. <view class="btn flex justify-between">
  15. <view @click="save">保存二维码到手机相册</view>
  16. <view>帮助</view>
  17. </view>
  18. <view class="input flex">
  19. <input type="text" placeholder="请输入" placeholder-class="place-class" v-model="aliAcc" />
  20. <view class="bind" @click="bind">
  21. 绑定
  22. </view>
  23. </view>
  24. </view>
  25. <view class="tips">
  26. 支付宝刷脸AI柜,需要绑定操作员的支付宝账号,操作员刷脸操作货柜时,系统将对操作员的支付宝账号进行授权。
  27. </view>
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. import {
  33. updateByAli
  34. } from "@/api/device/device.js"
  35. import {
  36. update
  37. } from "@/api/system/employee.js"
  38. import {
  39. imgDownLoad
  40. } from '@/utils/download.js'
  41. export default {
  42. data() {
  43. return {
  44. fullHeight: 0,
  45. aliAcc: null,
  46. userId: null,
  47. }
  48. },
  49. onLoad(o) {
  50. let _this = this;
  51. const query = uni.createSelectorQuery().in(this);
  52. query.select(".content").boundingClientRect((data) => {
  53. uni.getSystemInfo({
  54. success(res) {
  55. // 针对iPhone X等机型底部安全距离做适配
  56. const model = res.model;
  57. const modelInclude = [
  58. "iPhone X",
  59. 'iPhone XR',
  60. "iPhone XS",
  61. "iPhone XS MAX",
  62. "iPhone 12/13 mini",
  63. "iPhone 12/13 (Pro)",
  64. "iPhone 12/13 Pro Max",
  65. "iPhone 14 Pro Max"
  66. ];
  67. let safeDistance = modelInclude.includes(model)
  68. //动态设置商品区域高度
  69. console.log(res.windowHeight, data.top)
  70. if (safeDistance) {
  71. _this.fullHeight = res.windowHeight - data.top - 54 + 'px';
  72. } else {
  73. _this.fullHeight = res.windowHeight - data.top - 20 + 'px';
  74. }
  75. },
  76. });
  77. }).exec();
  78. if (o.userId) {
  79. this.userId = o.userId
  80. }
  81. },
  82. methods: {
  83. async bind() {
  84. if (!this.aliAcc) {
  85. this.$modal.msg('请输入支付宝用户id')
  86. return
  87. }
  88. if (!this.userId) {
  89. //商户绑定
  90. await this.mercUpdate()
  91. } else {
  92. //员工绑定
  93. await this.partnerUpdate()
  94. }
  95. console.log('成功')
  96. this.$modal.msg('绑定成功~')
  97. setTimeout(() => {
  98. this.$tab.navigateBack()
  99. }, 1000)
  100. },
  101. mercUpdate() {
  102. return new Promise((resolve, reject) => {
  103. updateByAli({
  104. aliUserId: this.aliAcc,
  105. }).then(res => {
  106. resolve(res)
  107. }).catch(err => {
  108. reject(res)
  109. })
  110. })
  111. },
  112. partnerUpdate() {
  113. return new Promise((resolve, reject) => {
  114. update({
  115. aliUserId: this.aliAcc,
  116. userId: this.userId
  117. }).then(res => {
  118. resolve(res)
  119. }).catch(err => {
  120. reject(res)
  121. })
  122. })
  123. },
  124. save() {
  125. let imgUrl = 'https://ossfile.mxrvending.com/assets/xy_merc_mini/images/alipayUid.png'
  126. imgDownLoad(imgUrl).then(res=>{
  127. uni.showToast({
  128. title: '保存成功~',
  129. })
  130. }).catch(err=>{
  131. uni.showToast({
  132. title: '保存失败,请重试!',
  133. })
  134. })
  135. },
  136. }
  137. }
  138. </script>
  139. <style lang="scss" scoped>
  140. .container {
  141. position: relative;
  142. .content {
  143. background-color: #fff;
  144. width: 724rpx;
  145. margin: 20rpx 13rpx 0;
  146. overflow: hidden;
  147. border-radius: 12rpx;
  148. .top {
  149. .btn {
  150. width: 400rpx;
  151. color: #3876f3;
  152. text-decoration: underline;
  153. margin-top: 50rpx;
  154. }
  155. .input {
  156. width: 460rpx;
  157. line-height: 80rpx;
  158. height: 80rpx;
  159. margin-top: 70rpx;
  160. >input {
  161. line-height: 80rpx;
  162. height: 80rpx;
  163. width: 76%;
  164. background-color: #f6f8fb;
  165. padding: 0 30rpx;
  166. border-top-left-radius: 18rpx;
  167. border-bottom-left-radius: 18rpx;
  168. }
  169. >view {
  170. width: 24%;
  171. text-align: center;
  172. border-top-right-radius: 18rpx;
  173. border-bottom-right-radius: 18rpx;
  174. background-color: #3876f3;
  175. color: #fff;
  176. }
  177. }
  178. .place-class {
  179. color: #dcdcdc;
  180. }
  181. }
  182. .tips {
  183. background-color: #ebf2ff;
  184. padding: 16rpx 20rpx;
  185. color: #3876f3;
  186. font-size: 26rpx;
  187. line-height: 40rpx;
  188. }
  189. }
  190. .img {
  191. width: 400rpx;
  192. height: 400rpx;
  193. margin-top: 70rpx;
  194. }
  195. .canvas-box {
  196. position: absolute;
  197. left: -1000rpx;
  198. }
  199. }
  200. </style>