123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- <template>
- <view class="container">
- <u-navbar leftIconColor="#fff" titleStyle="color:#fff;fontSize:36rpx;" :autoBack="true" bgColor="#2C6FF3"
- :placeholder="true" title="账号绑定">
- </u-navbar>
- <view class="content flex flex-direction justify-between" :style="{height:fullHeight}">
- <view class="top flex flex-direction align-center">
- <view class="img">
- <u-image width="400rpx" height="400rpx"
- src="https://cdn.ossfile.mxrvending.com/assets/xy_merc_mini/images/alipayUid.png"
- mode="widthFix" :lazy-load="true">
- </u-image>
- </view>
- <view class="btn flex justify-between">
- <view @click="save">保存二维码到手机相册</view>
- <view>帮助</view>
- </view>
- <view class="input flex">
- <input type="text" placeholder="请输入" placeholder-class="place-class" v-model="aliAcc" />
- <view class="bind" @click="bind">
- 绑定
- </view>
- </view>
- </view>
- <view class="tips">
- 支付宝刷脸AI柜,需要绑定操作员的支付宝账号,操作员刷脸操作货柜时,系统将对操作员的支付宝账号进行授权。
- </view>
- </view>
- </view>
- </template>
- <script>
- import {
- updateByAli
- } from "@/api/device/device.js"
- import {
- update
- } from "@/api/system/employee.js"
- import {
- imgDownLoad
- } from '@/utils/download.js'
- export default {
- data() {
- return {
- fullHeight: 0,
- aliAcc: null,
- userId: null,
- }
- },
- onLoad(o) {
- let _this = this;
- const query = uni.createSelectorQuery().in(this);
- query.select(".content").boundingClientRect((data) => {
- uni.getSystemInfo({
- success(res) {
- // 针对iPhone X等机型底部安全距离做适配
- const model = res.model;
- const modelInclude = [
- "iPhone X",
- 'iPhone XR',
- "iPhone XS",
- "iPhone XS MAX",
- "iPhone 12/13 mini",
- "iPhone 12/13 (Pro)",
- "iPhone 12/13 Pro Max",
- "iPhone 14 Pro Max"
- ];
- let safeDistance = modelInclude.includes(model)
- //动态设置商品区域高度
- console.log(res.windowHeight, data.top)
- if (safeDistance) {
- _this.fullHeight = res.windowHeight - data.top - 54 + 'px';
- } else {
- _this.fullHeight = res.windowHeight - data.top - 20 + 'px';
- }
- },
- });
- }).exec();
- if (o.userId) {
- this.userId = o.userId
- }
- },
- methods: {
- async bind() {
- if (!this.aliAcc) {
- this.$modal.msg('请输入支付宝用户id')
- return
- }
- if (!this.userId) {
- //商户绑定
- await this.mercUpdate()
- } else {
- //员工绑定
- await this.partnerUpdate()
- }
- console.log('成功')
- this.$modal.msg('绑定成功~')
- setTimeout(() => {
- this.$tab.navigateBack()
- }, 1000)
- },
- mercUpdate() {
- return new Promise((resolve, reject) => {
- updateByAli({
- aliUserId: this.aliAcc,
- }).then(res => {
- resolve(res)
- }).catch(err => {
- reject(res)
- })
- })
- },
- partnerUpdate() {
- return new Promise((resolve, reject) => {
- update({
- aliUserId: this.aliAcc,
- userId: this.userId
- }).then(res => {
- resolve(res)
- }).catch(err => {
- reject(res)
- })
- })
- },
- save() {
- let imgUrl = 'https://ossfile.mxrvending.com/assets/xy_merc_mini/images/alipayUid.png'
- imgDownLoad(imgUrl).then(res=>{
- uni.showToast({
- title: '保存成功~',
- })
- }).catch(err=>{
- uni.showToast({
- title: '保存失败,请重试!',
- })
- })
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- .container {
- position: relative;
- .content {
- background-color: #fff;
- width: 724rpx;
- margin: 20rpx 13rpx 0;
- overflow: hidden;
- border-radius: 12rpx;
- .top {
- .btn {
- width: 400rpx;
- color: #3876f3;
- text-decoration: underline;
- margin-top: 50rpx;
- }
- .input {
- width: 460rpx;
- line-height: 80rpx;
- height: 80rpx;
- margin-top: 70rpx;
- >input {
- line-height: 80rpx;
- height: 80rpx;
- width: 76%;
- background-color: #f6f8fb;
- padding: 0 30rpx;
- border-top-left-radius: 18rpx;
- border-bottom-left-radius: 18rpx;
- }
- >view {
- width: 24%;
- text-align: center;
- border-top-right-radius: 18rpx;
- border-bottom-right-radius: 18rpx;
- background-color: #3876f3;
- color: #fff;
- }
- }
- .place-class {
- color: #dcdcdc;
- }
- }
- .tips {
- background-color: #ebf2ff;
- padding: 16rpx 20rpx;
- color: #3876f3;
- font-size: 26rpx;
- line-height: 40rpx;
- }
- }
- .img {
- width: 400rpx;
- height: 400rpx;
- margin-top: 70rpx;
- }
- .canvas-box {
- position: absolute;
- left: -1000rpx;
- }
- }
- </style>
|