| @@ -1,5 +1,5 @@ | |||||
| const request = require('./utils/request') | |||||
| import { timestampToTime } from './utils/util' | import { timestampToTime } from './utils/util' | ||||
| const request = require('./utils/request') | |||||
| App({ | App({ | ||||
| globalData: { | globalData: { | ||||
| @@ -1,3 +1,8 @@ | |||||
| const app = getApp() | |||||
| import request from '../../utils/request' | |||||
| import Dialog from '@vant/weapp/dialog/dialog'; | |||||
| const { appId } = require("../../utils/request"); | |||||
| // pages/checkImg/checkImg.ts | // pages/checkImg/checkImg.ts | ||||
| Page({ | Page({ | ||||
| @@ -6,24 +11,9 @@ Page({ | |||||
| */ | */ | ||||
| data: { | data: { | ||||
| currentIndex: 0, | currentIndex: 0, | ||||
| swiperList: [ | |||||
| { | |||||
| id: "1", | |||||
| src: "https://suimang.oss-accelerate.aliyuncs.com/capi/2023-09-21/4f3cf1dea65142a2945d5412bee85ca2.jpg?x-oss-process=image/resize,w_10000/quality,q_60" | |||||
| }, | |||||
| { | |||||
| id: "2", | |||||
| src: "https://suimang.oss-accelerate.aliyuncs.com/capi/2023-09-21/4f3cf1dea65142a2945d5412bee85ca2.jpg?x-oss-process=image/resize,w_10000/quality,q_60" | |||||
| }, | |||||
| { | |||||
| id: "3", | |||||
| src: "https://suimang.oss-accelerate.aliyuncs.com/capi/2023-09-21/4f3cf1dea65142a2945d5412bee85ca2.jpg?x-oss-process=image/resize,w_10000/quality,q_60" | |||||
| }, | |||||
| { | |||||
| id: "4", | |||||
| src: "https://suimang.oss-accelerate.aliyuncs.com/capi/2023-09-21/4f3cf1dea65142a2945d5412bee85ca2.jpg?x-oss-process=image/resize,w_10000/quality,q_60" | |||||
| } | |||||
| ] | |||||
| id: "", | |||||
| swiperList: [], | |||||
| title: "" | |||||
| }, | }, | ||||
| /** | /** | ||||
| @@ -31,12 +21,44 @@ Page({ | |||||
| */ | */ | ||||
| onLoad(options) { | onLoad(options) { | ||||
| console.log(options); | console.log(options); | ||||
| this.setData({ | |||||
| id: options.id | |||||
| }) | |||||
| app.tokenCallBack = token => { | |||||
| if (!token) { | |||||
| wx.redirectTo({ | |||||
| url: '/pages/login/login', | |||||
| }) | |||||
| } else { | |||||
| this.getImageDetail(options.id) | |||||
| } | |||||
| } | |||||
| }, | }, | ||||
| /** | /** | ||||
| * 生命周期函数--监听页面显示 | * 生命周期函数--监听页面显示 | ||||
| */ | */ | ||||
| onShow() { | onShow() { | ||||
| const isLogin = wx.getStorageSync('token') | |||||
| if (isLogin) { | |||||
| this.getImageDetail(this.data.id) | |||||
| } | |||||
| }, | |||||
| getImageDetail(id) { | |||||
| const that = this | |||||
| console.log(id, 'id'); | |||||
| request.get({ | |||||
| url: `/api/digitalAvatarPhoto/findById?id=${id}` | |||||
| }).then(res => { | |||||
| console.log(res, 'getImageDetail'); | |||||
| that.setData({ | |||||
| swiperList: res.data.photoList, | |||||
| title: res.data.title, | |||||
| }) | |||||
| }).catch(err => { | |||||
| console.log(err, 'err'); | |||||
| }) | |||||
| }, | }, | ||||
| @@ -50,7 +72,7 @@ Page({ | |||||
| previewImage() { | previewImage() { | ||||
| const array = [] | const array = [] | ||||
| this.data.swiperList.forEach(item => { | this.data.swiperList.forEach(item => { | ||||
| array.push(item.src) | |||||
| array.push(item.image) | |||||
| }) | }) | ||||
| wx.previewImage({ | wx.previewImage({ | ||||
| urls: array, | urls: array, | ||||
| @@ -71,7 +93,7 @@ Page({ | |||||
| const list = this.data.swiperList | const list = this.data.swiperList | ||||
| const filePath = "zhixiangImg.png" | const filePath = "zhixiangImg.png" | ||||
| const url = list[index].src | |||||
| const url = list[index].image | |||||
| wx.downloadFile({ | wx.downloadFile({ | ||||
| url, | url, | ||||
| @@ -1,9 +1,9 @@ | |||||
| <!--pages/checkImg/checkImg.wxml--> | <!--pages/checkImg/checkImg.wxml--> | ||||
| <view class="name">模板名称</view> | |||||
| <view class="name">{{title}}</view> | |||||
| <swiper class="imageList" current="{{ currentIndex }}" bindchange="swiperChanged"> | <swiper class="imageList" current="{{ currentIndex }}" bindchange="swiperChanged"> | ||||
| <swiper-item wx:for="{{ swiperList }}" wx:key="index"> | <swiper-item wx:for="{{ swiperList }}" wx:key="index"> | ||||
| <image src="{{ item.src }}" mode="widthFix" bindtap="previewImage" data-src="{{ item.src }}" /> | |||||
| <image src="{{ item.image }}" mode="widthFix" bindtap="previewImage" data-image="{{ item.image }}" /> | |||||
| </swiper-item> | </swiper-item> | ||||
| </swiper> | </swiper> | ||||
| @@ -1,4 +1,5 @@ | |||||
| const app = getApp() | const app = getApp() | ||||
| const updateManager = wx.getUpdateManager() | |||||
| import request from '../../utils/request' | import request from '../../utils/request' | ||||
| import { timestampToTime } from '../../utils/util' | import { timestampToTime } from '../../utils/util' | ||||
| import Dialog from '@vant/weapp/dialog/dialog'; | import Dialog from '@vant/weapp/dialog/dialog'; | ||||
| @@ -6,107 +7,67 @@ import Dialog from '@vant/weapp/dialog/dialog'; | |||||
| Page({ | Page({ | ||||
| data: { | data: { | ||||
| isLogin: false, | isLogin: false, | ||||
| itemList: [ | |||||
| { id: 1 }, | |||||
| { id: 2 }, | |||||
| { id: 3 }, | |||||
| { id: 4 }, | |||||
| { id: 5 }, | |||||
| { id: 6 }, | |||||
| ], | |||||
| itemList: [], | |||||
| showPrivacy: false, | showPrivacy: false, | ||||
| avatarUrl: "../../asset/icon/logo-5.png" | |||||
| currentIndex: 1, | |||||
| avatarUrl: "../../asset/icon/logo-5.png", | |||||
| timer: null | |||||
| }, | }, | ||||
| // 事件处理函数 | |||||
| clickPrivacy(e) { | |||||
| }, | |||||
| closePrivacy() { | |||||
| wx.exitMiniProgram() | |||||
| }, | |||||
| onLoad(option) { | |||||
| wx.hideHomeButton() | |||||
| getPrivacySetting() { | |||||
| const canIUsePrivacy = wx.canIUse('getPrivacySetting') | |||||
| console.log(canIUsePrivacy, 'canIUse getPrivacySetting') | |||||
| if (canIUsePrivacy) { | |||||
| wx.getPrivacySetting({ | |||||
| success: res => { | |||||
| console.log(res, 'getPrivacySetting') // 返回结果为: res = { needAuthorization: true/false, privacyContractName: '《xxx隐私保护指引》' } | |||||
| if (res.needAuthorization) { | |||||
| // 需要弹出隐私协议 | |||||
| this.setData({ | |||||
| showPrivacy: true | |||||
| }) | |||||
| } else { | |||||
| // this.setData({ | |||||
| // showPrivacy: true | |||||
| // }) | |||||
| // 用户已经同意过隐私协议,所以不需要再弹出隐私协议,也能调用已声明过的隐私接口 | |||||
| // wx.getUserProfile() | |||||
| // wx.chooseMedia() | |||||
| // wx.getClipboardData() | |||||
| // wx.startRecord() | |||||
| // this.setData({ | |||||
| // showPrivacy: true | |||||
| // }) | |||||
| } | |||||
| }, | |||||
| fail: () => { }, | |||||
| complete: () => { } | |||||
| // 携带机器识别码进入 | |||||
| if (option.machineQrcodeId) { | |||||
| this.setData({ | |||||
| machineQrcodeId: option.machineQrcodeId | |||||
| }) | }) | ||||
| } | } | ||||
| }, | |||||
| handleAgreePrivacyAuthorization() { | |||||
| console.log('Privacy Agreed!'); | |||||
| this.setData({ | |||||
| showPrivacy: false | |||||
| }) | |||||
| // 用户同意隐私协议事件回调 | |||||
| // 用户点击了同意,之后所有已声明过的隐私接口和组件都可以调用了 | |||||
| // wx.getUserProfile() | |||||
| // wx.chooseMedia() | |||||
| // wx.getClipboardData() | |||||
| // wx.startRecord() | |||||
| }, | |||||
| handleOpenPrivacyContract() { | |||||
| // 打开隐私协议页面 | |||||
| wx.openPrivacyContract({ | |||||
| success: () => { | |||||
| // this.setData({ | |||||
| // showPrivacy: false | |||||
| // }) | |||||
| }, // 打开成功 | |||||
| fail: () => { }, // 打开失败 | |||||
| complete: () => { } | |||||
| // 更新提示 | |||||
| updateManager.onUpdateReady(function () { | |||||
| wx.showModal({ | |||||
| title: '更新提示', | |||||
| content: '新版本已经准备好,是否重启应用?', | |||||
| success: function (res) { | |||||
| if (res.confirm) { | |||||
| // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 | |||||
| updateManager.applyUpdate() | |||||
| } | |||||
| } | |||||
| }) | |||||
| }) | }) | ||||
| }, | |||||
| onLoad(option) { | |||||
| wx.hideHomeButton() | |||||
| this.getPrivacySetting() | |||||
| // 直接进入页面,token回调返回时 | |||||
| app.tokenCallBack = res => { | |||||
| this.setData({ | |||||
| isLogin: res | |||||
| }) | |||||
| wx.showLoading({ | |||||
| title: '加载中', | |||||
| }) | |||||
| this.getImageList(10, this.data.currentIndex) | |||||
| } | |||||
| }, | }, | ||||
| onShow() { | onShow() { | ||||
| const isLogin = wx.getStorageSync('token') | const isLogin = wx.getStorageSync('token') | ||||
| const isPay = wx.getStorageSync('isPay') | |||||
| this.setData({ | this.setData({ | ||||
| isLogin | |||||
| isLogin, | |||||
| currentIndex: 1 | |||||
| }) | }) | ||||
| app.tokenCallBack = res => { | |||||
| this.setData({ | |||||
| isLogin: res | |||||
| if (isLogin) { | |||||
| wx.showLoading({ | |||||
| title: '加载中', | |||||
| }) | }) | ||||
| this.getImageList(10, this.data.currentIndex) | |||||
| if (this.data.machineQrcodeId && !isPay) { | |||||
| this.getPayInfo(this.data.machineQrcodeId) | |||||
| } | |||||
| } | } | ||||
| }, | }, | ||||
| getUserPhone(e) { | |||||
| const sessionKey = wx.getStorageSync('sessionKey') | |||||
| this.doGetUserPhone(e.detail.encryptedData, e.detail.iv, sessionKey, request.appId) | |||||
| }, | |||||
| /** 获取手机号授权 */ | /** 获取手机号授权 */ | ||||
| doGetUserPhone(encryptedData, iv, sessionKey, appId) { | doGetUserPhone(encryptedData, iv, sessionKey, appId) { | ||||
| request.post({ | request.post({ | ||||
| @@ -129,25 +90,52 @@ Page({ | |||||
| }) | }) | ||||
| }, | }, | ||||
| showMore() { | |||||
| // 删除作品 | |||||
| showMore(e) { | |||||
| const that = this | |||||
| const id = e.currentTarget.dataset.id | |||||
| Dialog.confirm({ | Dialog.confirm({ | ||||
| title: '删除作品', | title: '删除作品', | ||||
| message: '确定要删除这个作品吗?', | message: '确定要删除这个作品吗?', | ||||
| }) | }) | ||||
| .then(() => { | .then(() => { | ||||
| // on confirm | |||||
| that.doDeleta(id) | |||||
| }) | }) | ||||
| .catch(() => { | .catch(() => { | ||||
| // on cancel | |||||
| }); | }); | ||||
| }, | }, | ||||
| doDeleta(id) { | |||||
| const that = this | |||||
| const data = { | |||||
| id | |||||
| } | |||||
| request.post({ | |||||
| url: `/api/digitalAvatarPhoto/delete`, | |||||
| data | |||||
| }).then(res => { | |||||
| console.log(res, 'res'); | |||||
| wx.showToast({ | |||||
| title: '删除成功!', | |||||
| icon: "success" | |||||
| }) | |||||
| that.getImageList(10, 1) | |||||
| }).catch(err => { | |||||
| console.log(err, 'err'); | |||||
| wx.showToast({ | |||||
| title: '删除失败!', | |||||
| icon: "error" | |||||
| }) | |||||
| }) | |||||
| }, | |||||
| goLogin() { | goLogin() { | ||||
| wx.redirectTo({ | wx.redirectTo({ | ||||
| url: '/pages/login/login', | url: '/pages/login/login', | ||||
| }) | }) | ||||
| }, | }, | ||||
| // 查看作品详情 | |||||
| goCheckImage(e) { | goCheckImage(e) { | ||||
| console.log(e, 'e'); | console.log(e, 'e'); | ||||
| const id = e.currentTarget.dataset.id | const id = e.currentTarget.dataset.id | ||||
| @@ -156,6 +144,158 @@ Page({ | |||||
| }) | }) | ||||
| }, | }, | ||||
| /** 获取作品列表 */ | |||||
| getImageList(pageSize, pageNum) { | |||||
| const that = this | |||||
| request.get({ | |||||
| url: `/api/digitalAvatarPhoto/list?pageSize=${pageSize}&pageNum=${pageNum}` | |||||
| }).then(res => { | |||||
| console.log(res, 'getImageList'); | |||||
| const list = res.data.list | |||||
| list.forEach(item => { | |||||
| item.createDate = timestampToTime(item.createDate, 'YYYY-MM-DD hh:mm:ss') | |||||
| }) | |||||
| if (pageNum == 1) { | |||||
| this.setData({ | |||||
| itemList: list | |||||
| }) | |||||
| } else { | |||||
| const tempList = that.data.itemList | |||||
| list.forEach(item => { | |||||
| tempList.push(item) | |||||
| }) | |||||
| this.setData({ | |||||
| itemList: tempList | |||||
| }) | |||||
| } | |||||
| if (!res.data.endRow) { | |||||
| wx.showToast({ | |||||
| title: '已加载全部写真', | |||||
| icon: "success" | |||||
| }) | |||||
| } | |||||
| wx.hideLoading() | |||||
| }).catch(err => { | |||||
| console.log(err, 'err'); | |||||
| wx.hideLoading() | |||||
| }) | |||||
| }, | |||||
| // 下来加载更多 | |||||
| loadMoreData() { | |||||
| const currentIndex = this.data.currentIndex + 1 | |||||
| this.setData({ | |||||
| currentIndex | |||||
| }) | |||||
| wx.showLoading({ | |||||
| title: '加载中', | |||||
| }) | |||||
| this.getImageList(10, currentIndex) | |||||
| }, | |||||
| // 获取支付信息 | |||||
| getPayInfo(machineQrcodeId) { | |||||
| const that = this | |||||
| const openId = wx.getStorageSync('openId') | |||||
| const data = { | |||||
| payVendor: 1, | |||||
| productId: 1, | |||||
| machineQrcodeId, | |||||
| openId | |||||
| } | |||||
| request.post({ | |||||
| url: '/api/productOrder/pay_screen', | |||||
| data | |||||
| }).then(res => { | |||||
| console.log(res, 'res'); | |||||
| const data = { | |||||
| timeStamp: res.data.timeStamp, | |||||
| nonceStr: res.data.nonceStr, | |||||
| package: res.data.package, | |||||
| signType: res.data.signType, | |||||
| paySign: res.data.paySign, | |||||
| payOrderId: res.data.payOrderId | |||||
| } | |||||
| that.doPay(data) | |||||
| }).catch(err => { | |||||
| console.log(err, 'err'); | |||||
| wx.showToast({ | |||||
| title: '订单信息获取失败,请重新扫码', | |||||
| icon: "none" | |||||
| }) | |||||
| }) | |||||
| }, | |||||
| // 拉起收银台 | |||||
| doPay(data) { | |||||
| const that = this | |||||
| // 进入此阶段,无论支付是否成功,不再拉起收银台 | |||||
| wx.setStorageSync('isPay', true) | |||||
| wx.requestPayment({ | |||||
| timeStamp: data.timeStamp, | |||||
| nonceStr: data.nonceStr, | |||||
| package: data.package, | |||||
| signType: data.signType ? data.signType : "MD5", | |||||
| paySign: data.paySign, | |||||
| success: res => { | |||||
| wx.showLoading({ | |||||
| title: '订单处理中', | |||||
| }) | |||||
| // 检查支付状态 | |||||
| that.setData({ | |||||
| timer: setInterval(() => { | |||||
| that.checkPayStatus(data.payOrderId, true) | |||||
| }, 1000) | |||||
| }) | |||||
| }, | |||||
| fail: res => { | |||||
| console.log(res, 'Fail!!!!'); | |||||
| wx.showLoading({ | |||||
| title: '订单处理中', | |||||
| }) | |||||
| // 检查支付状态 | |||||
| that.setData({ | |||||
| timer: setInterval(() => { | |||||
| that.checkPayStatus(data.payOrderId, false) | |||||
| }, 1000) | |||||
| }) | |||||
| // wx.showToast({ | |||||
| // title: '支付失败,请重新扫码支付', | |||||
| // icon: 'none' | |||||
| // }) | |||||
| }, | |||||
| complete: res => { } | |||||
| }); | |||||
| }, | |||||
| checkPayStatus(id, isSuccess) { | |||||
| const that = this | |||||
| request.get({ | |||||
| url: `/api/productOrder/findStatus?orderNumber=${id}` | |||||
| }).then(res => { | |||||
| console.log(res, 'res'); | |||||
| const timer = that.data.timer | |||||
| if (res.data.orderStatus == 3) { | |||||
| clearInterval(timer) | |||||
| wx.showToast({ | |||||
| title: '支付成功!', | |||||
| icon: "success" | |||||
| }) | |||||
| wx.hideLoading() | |||||
| } else if ((res.data.orderStatus == 1 && !isSuccess) || res.data.orderStatus == 4) { | |||||
| clearInterval(timer) | |||||
| wx.showToast({ | |||||
| title: '支付取消!', | |||||
| icon: "error" | |||||
| }) | |||||
| wx.hideLoading() | |||||
| } | |||||
| }).catch(err => { | |||||
| console.log(err, 'err'); | |||||
| }) | |||||
| }, | |||||
| onShareAppMessage() { | onShareAppMessage() { | ||||
| const promise = new Promise(resolve => { | const promise = new Promise(resolve => { | ||||
| setTimeout(() => { | setTimeout(() => { | ||||
| @@ -10,23 +10,23 @@ | |||||
| <image src="{{ avatarUrl }}" mode="" /> | <image src="{{ avatarUrl }}" mode="" /> | ||||
| </view> | </view> | ||||
| <view wx:if="{{ !isLogin }}" class="nickname">微信用户</view> | <view wx:if="{{ !isLogin }}" class="nickname">微信用户</view> | ||||
| <view wx:if="{{ isLogin }}" class="nickname">用户名</view> | |||||
| <view wx:if="{{ isLogin }}" class="nickname">微信用户</view> | |||||
| </block> | </block> | ||||
| <block wx:if="{{ isLogin }}"> | <block wx:if="{{ isLogin }}"> | ||||
| <view class="tab">我的写真</view> | <view class="tab">我的写真</view> | ||||
| <scroll-view class="scrollView" type="list" scroll-y scroll-with-animatio> | |||||
| <scroll-view class="scrollView" type="list" scroll-y scroll-with-animatio bindscrolltolower="loadMoreData"> | |||||
| <view wx:for="{{itemList}}" class="item" wx:key="index"> | <view wx:for="{{itemList}}" class="item" wx:key="index"> | ||||
| <view class="top"> | <view class="top"> | ||||
| <view class="modelName">name</view> | |||||
| <view class="date">2023-10-1 12:43:14</view> | |||||
| <view class="more" bindtap="showMore"> | |||||
| <view class="modelName">{{ item.title }}</view> | |||||
| <view class="date">{{ item.createDate }}</view> | |||||
| <view class="more" bindtap="showMore" data-id="{{ item.id }}"> | |||||
| <image src="../../asset/icon/more.png" mode="widthFix" /> | <image src="../../asset/icon/more.png" mode="widthFix" /> | ||||
| </view> | </view> | ||||
| </view> | </view> | ||||
| <view class="photoList" bindtap="goCheckImage" data-id="{{ item.id }}"> | <view class="photoList" bindtap="goCheckImage" data-id="{{ item.id }}"> | ||||
| <image wx:for="{{[1,1,1,1]}}" wx:key="index" src="../../asset/image/test.png" mode="widthFix" /> | |||||
| <image wx:for="{{ item.photoList }}" wx:for-index="childIndex" wx:for-item="chileItem" wx:key="childIndex" src="{{ chileItem.image }}" mode="widthFix" /> | |||||
| </view> | </view> | ||||
| </view> | </view> | ||||
| </scroll-view> | </scroll-view> | ||||
| @@ -8,13 +8,29 @@ Page({ | |||||
| * 页面的初始数据 | * 页面的初始数据 | ||||
| */ | */ | ||||
| data: { | data: { | ||||
| isAgree: false | |||||
| isAgree: false, | |||||
| tmpUserId: "" | |||||
| }, | }, | ||||
| /** | /** | ||||
| * 生命周期函数--监听页面加载 | * 生命周期函数--监听页面加载 | ||||
| */ | */ | ||||
| onLoad() { | |||||
| onLoad(options) { | |||||
| console.log(options, 'options'); | |||||
| wx.hideHomeButton() | |||||
| if (options.scene) { | |||||
| this.setData({ | |||||
| tmpUserId: options.scene | |||||
| }) | |||||
| } | |||||
| app.tokenCallBack = token => { | |||||
| if (token) { | |||||
| this.bindUser() | |||||
| } else { | |||||
| } | |||||
| } | |||||
| }, | }, | ||||
| @@ -39,10 +55,11 @@ Page({ | |||||
| openId, | openId, | ||||
| appId, | appId, | ||||
| encryptedData, | encryptedData, | ||||
| iv, | |||||
| iv | |||||
| } | } | ||||
| that.loginWithPhone(data) | that.loginWithPhone(data) | ||||
| } else { | } else { | ||||
| that.getPhoneNumberFail() | |||||
| wx.showToast({ | wx.showToast({ | ||||
| title: '授权失败', | title: '授权失败', | ||||
| icon: "error" | icon: "error" | ||||
| @@ -68,6 +85,7 @@ Page({ | |||||
| } | } | ||||
| }, | }, | ||||
| // 用户协议状态变更 | |||||
| checkboxChange(e) { | checkboxChange(e) { | ||||
| if (e.detail.value[0]) { | if (e.detail.value[0]) { | ||||
| this.setData({ | this.setData({ | ||||
| @@ -80,6 +98,7 @@ Page({ | |||||
| } | } | ||||
| }, | }, | ||||
| // 查看用户协议 | |||||
| goPro() { | goPro() { | ||||
| wx.navigateTo({ | wx.navigateTo({ | ||||
| url: '/pages/userProtocol/userProtocol', | url: '/pages/userProtocol/userProtocol', | ||||
| @@ -87,29 +106,64 @@ Page({ | |||||
| }, | }, | ||||
| loginWithPhone(data) { | loginWithPhone(data) { | ||||
| const that = this | |||||
| request.post({ | request.post({ | ||||
| url: '/api/miniApp/loginPhone', | url: '/api/miniApp/loginPhone', | ||||
| data | data | ||||
| }).then(res => { | }).then(res => { | ||||
| // 获取手机号之后,绑定用户与机器 | |||||
| that.bindUser() | |||||
| }).catch(err => { | |||||
| console.log(err, 'err'); | |||||
| }) | |||||
| }, | |||||
| // 绑定用户与机器 | |||||
| bindUser() { | |||||
| const openId = wx.getStorageSync('openId') | |||||
| const tmpUserId = this.data.tmpUserId | |||||
| const data = { | |||||
| openId, | |||||
| tmpUserId | |||||
| } | |||||
| request.post({ | |||||
| url: '/api/miniApp/bindUser', | |||||
| data | |||||
| }).then(res => { | |||||
| console.log(res, 'res'); | |||||
| wx.showToast({ | wx.showToast({ | ||||
| title: '登录成功!', | title: '登录成功!', | ||||
| icon: "success", | icon: "success", | ||||
| duration: 1500, | duration: 1500, | ||||
| complete: () => { | complete: () => { | ||||
| setTimeout(() => { | setTimeout(() => { | ||||
| wx.redirectTo({ | |||||
| url: '/pages/index/index', | |||||
| }) | |||||
| if (tmpUserId) { | |||||
| wx.setStorageSync('isPay', false) | |||||
| wx.redirectTo({ | |||||
| url: `/pages/index/index?machineQrcodeId=${tmpUserId}`, | |||||
| }) | |||||
| } else { | |||||
| wx.redirectTo({ | |||||
| url: `/pages/index/index`, | |||||
| }) | |||||
| } | |||||
| }, 1500); | }, 1500); | ||||
| } | } | ||||
| }) | }) | ||||
| }).catch(err => { | }).catch(err => { | ||||
| console.log(err, 'err'); | console.log(err, 'err'); | ||||
| wx.showToast({ | |||||
| title: '服务器异常,请稍后再试', | |||||
| icon: "none" | |||||
| }) | |||||
| }) | }) | ||||
| }, | }, | ||||
| getPhoneNumberFail() { | |||||
| }, | |||||
| /** | /** | ||||
| * 页面相关事件处理函数--监听用户下拉动作 | * 页面相关事件处理函数--监听用户下拉动作 | ||||
| */ | */ | ||||
| @@ -20,9 +20,10 @@ Page({ | |||||
| * 生命周期函数--监听页面加载 | * 生命周期函数--监听页面加载 | ||||
| */ | */ | ||||
| onLoad(options) { | onLoad(options) { | ||||
| if (options.id) { | |||||
| console.log(options, 'options'); | |||||
| if (options.scene) { | |||||
| this.setData({ | this.setData({ | ||||
| id: options.id | |||||
| id: options.scene | |||||
| }) | }) | ||||
| } | } | ||||
| }, | }, | ||||
| @@ -42,6 +43,18 @@ Page({ | |||||
| chooseImage(e) { | chooseImage(e) { | ||||
| const that = this | const that = this | ||||
| const action = e.currentTarget.dataset.action | |||||
| if (action && that.data.tempFilePath) { | |||||
| that.setData({ | |||||
| showScanLine: true, | |||||
| isUploaded: true, | |||||
| isSuccess: false | |||||
| }) | |||||
| that.imgCheckByFace() | |||||
| return | |||||
| } | |||||
| wx.chooseMedia({ | wx.chooseMedia({ | ||||
| mediaType: ['image'], | mediaType: ['image'], | ||||
| sourceType: ['camera'], | sourceType: ['camera'], | ||||
| @@ -148,11 +161,12 @@ Page({ | |||||
| }, | }, | ||||
| success: res => { | success: res => { | ||||
| console.log(res, 'res'); | console.log(res, 'res'); | ||||
| const code = JSON.parse(res.data).code | |||||
| if (code == 200) { | |||||
| const data = JSON.parse(res.data) | |||||
| if (data.code == 200) { | |||||
| that.setData({ | that.setData({ | ||||
| showScanLine: false, | showScanLine: false, | ||||
| isSuccess: true | |||||
| isSuccess: true, | |||||
| onlineFilePath: data.data.url | |||||
| }) | }) | ||||
| wx.showToast({ | wx.showToast({ | ||||
| title: '上传成功!', | title: '上传成功!', | ||||
| @@ -179,7 +193,29 @@ Page({ | |||||
| // 确认照片 | // 确认照片 | ||||
| confirmImage() { | confirmImage() { | ||||
| const that = this | |||||
| const data = { | |||||
| id: this.data.id, | |||||
| image: this.data.onlineFilePath | |||||
| } | |||||
| request.post({ | |||||
| url: "/api/screenImg/addImage", | |||||
| data | |||||
| }).then(res => { | |||||
| console.log(res, 'res'); | |||||
| if (res.code == 200) { | |||||
| wx.showToast({ | |||||
| title: '照片上传成功!请在终端机上查看!', | |||||
| icon: "none" | |||||
| }) | |||||
| that.setData({ | |||||
| topTitle: "上传成功!" | |||||
| }) | |||||
| } | |||||
| }).catch(err => { | |||||
| console.log(err, 'err'); | |||||
| }) | |||||
| }, | }, | ||||
| /** | /** | ||||
| @@ -9,7 +9,8 @@ | |||||
| </view> | </view> | ||||
| <block wx:if="{{ !isSuccess }}"> | <block wx:if="{{ !isSuccess }}"> | ||||
| <button class="uploadImgBtn" bindtap="chooseImage">上传照片</button> | |||||
| <button class="uploadImgBtn" bindtap="chooseImage" data-action="upload">上传照片</button> | |||||
| <button wx:if="{{ tempFilePath }}" class="reUpload" bindtap="chooseImage">重新选择</button> | |||||
| </block> | </block> | ||||
| <block wx:if="{{ isSuccess }}"> | <block wx:if="{{ isSuccess }}"> | ||||
| @@ -1,3 +1,6 @@ | |||||
| // const BASEURL = "http://192.168.1.105:7600/C" | |||||
| const BASEURL = "https://zhixiangtest.malls.iformall.com/C" | |||||
| class request { | class request { | ||||
| constructor(address) { | constructor(address) { | ||||
| if (address) { | if (address) { | ||||
| @@ -12,12 +15,12 @@ class request { | |||||
| * @description 基地址 | * @description 基地址 | ||||
| * @returns {string} https://zhixiangtest.malls.iformall.com/C | * @returns {string} https://zhixiangtest.malls.iformall.com/C | ||||
| */ | */ | ||||
| baseUrl = 'https://zhixiangtest.malls.iformall.com/C' | |||||
| baseUrl = BASEURL | |||||
| /** | /** | ||||
| * 请求路径前缀 | * 请求路径前缀 | ||||
| */ | */ | ||||
| address = 'https://zhixiangtest.malls.iformall.com/C'; | |||||
| address = BASEURL | |||||
| /** | /** | ||||
| * 请求头 | * 请求头 | ||||
| */ | */ | ||||
| @@ -3,7 +3,7 @@ | |||||
| "projectname": "Metavatar_DCIM_Wapp", | "projectname": "Metavatar_DCIM_Wapp", | ||||
| "setting": { | "setting": { | ||||
| "compileHotReLoad": true, | "compileHotReLoad": true, | ||||
| "urlCheck": true | |||||
| "urlCheck": false | |||||
| }, | }, | ||||
| "libVersion": "3.0.1", | "libVersion": "3.0.1", | ||||
| "condition": { | "condition": { | ||||
| @@ -12,14 +12,14 @@ | |||||
| { | { | ||||
| "name": "", | "name": "", | ||||
| "pathName": "pages/login/login", | "pathName": "pages/login/login", | ||||
| "query": "", | |||||
| "query": "scene=865789927095844864", | |||||
| "launchMode": "default", | "launchMode": "default", | ||||
| "scene": null | "scene": null | ||||
| }, | }, | ||||
| { | { | ||||
| "name": "", | "name": "", | ||||
| "pathName": "pages/upload/upload", | "pathName": "pages/upload/upload", | ||||
| "query": "id=123456", | |||||
| "query": "id=1", | |||||
| "launchMode": "default", | "launchMode": "default", | ||||
| "scene": null | "scene": null | ||||
| }, | }, | ||||