123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835 |
- <template>
- <view>
- <view v-if="shangxian === '否'">
- <view class="padding">
- <view class="text-center padding-bottom text-red" v-if="status==3">
- 拒绝理由:{{form.auditContent}}
- </view>
- <view class="text-center padding-bottom text-red" v-if="status==1">审核中</view>
- <view class=" padding-lr bg-white " style="border-radius: 24rpx;">
- <u-form :model="form" ref="uForm" label-position="top" :label-style='lableStyle'>
- <u-form-item label="姓名" :border-bottom='true'>
- <u-input placeholder="请输入真实姓名" v-model="form.driverName" />
- </u-form-item>
- <!-- <u-form-item label="证件号码" :border-bottom='false'>
- <u-input placeholder="请填写(必填) " v-model="form.identityCardNumber" />
- </u-form-item> -->
- <u-form-item label="出生日期" :border-bottom='true'>
- <u-input placeholder="请填写(必填)" v-model="form.dateBirth" :disabled="true"
- @click="show = true" />
- </u-form-item>
- <u-form-item label="驾龄(年)" :border-bottom='true'>
- <u-input placeholder="请填写(必填) " v-model="form.drivingYears" />
- </u-form-item>
- <!-- <u-form-item label="省市区" :border-bottom='true'>
- <u-input placeholder="请选择位置(必填) " v-model="cityqu" :disabled="true" @click="openMap()" />
- </u-form-item> -->
- <u-form-item label="车辆品牌" :border-bottom='true'>
- <u-input placeholder="请输入车辆品牌(必填) " v-model="form.driverBrand" />
- </u-form-item>
- <u-form-item label="车牌号" :border-bottom='true'>
- <u-input placeholder="请输入车牌号(必填) " v-model="form.driverPlate" />
- </u-form-item>
- <u-form-item label="车辆颜色" :border-bottom='false'>
- <u-input placeholder="请输入车辆颜色(必填) " v-model="form.driverColor" />
- </u-form-item>
- </u-form>
- </view>
- <view class=" padding bg-white margin-top" style="border-radius: 24rpx;">
- <view class="text-bold text-black">上传身份证件</view>
- <view class="flex margin-top justify-between">
- <view style="width: 303rpx;height: 180rpx;">
- <view @click="addImages(1)"
- v-if="!form.frontIdentityCard">
- <image v-if="globalImages" :src="globalImages + 'imgs/static/upload/czsfzrx.png'" style="width: 303rpx;height: 180rpx;"></image>
- </view>
- <image @click="disabled? '':addImages(1)" v-else :src="form.frontIdentityCard"
- style="width: 303rpx;height: 180rpx;"></image>
- </view>
- <view style="width: 303rpx;height: 180rpx;">
- <view @click="addImages(2)"
- v-if="!form.backIdentityCard">
- <image v-if="globalImages" :src="globalImages + 'imgs/static/upload/czsfzfm.png'" style="width: 303rpx;height: 180rpx;"></image>
- </view>
- <image @click="disabled? '':addImages(2)" v-else :src="form.backIdentityCard"
- style="width: 303rpx;height: 180rpx;"></image>
- </view>
- </view>
-
- <view class="text-bold text-black margin-top-lg">上传车辆信息</view>
- <view class="flex margin-top justify-between">
- <view style="width: 303rpx;height: 180rpx;">
- <view @click="addImages(3)"
- v-if="!form.drivingLicense">
- <image v-if="globalImages" :src="globalImages + 'imgs/static/upload/czxszzbzm.png'" style="width: 303rpx;height: 180rpx;"></image>
- </view>
- <image @click="disabled? '':addImages(3)" v-else :src="form.drivingLicense"
- style="width: 303rpx;height: 180rpx;"></image>
- </view>
- <view style="width: 303rpx;height: 180rpx;">
- <view @click="addImages(4)"
- v-if="!form.driverLicense">
- <image v-if="globalImages" :src="globalImages + 'imgs/static/upload/czxszzm.png'" style="width: 303rpx;height: 180rpx;"></image>
- </view>
- <image @click="disabled? '':addImages(4)" v-else :src="form.driverLicense"
- style="width: 303rpx;height: 180rpx;"></image>
- </view>
- </view>
-
-
-
- <!-- <view>
- <view class="flex" style="overflow: hidden;flex-wrap: wrap;">
- <view v-if="drivingLicence.length">
- <view class="margin-top-sm flex margin-right-sm flex-wrap">
- <view v-for="(item,index) in drivingLicence" :key="index">
- <view class="flex"
- style="width: 200rpx;height: 200rpx;margin-right: 2rpx;position: relative;">
- <image :src="item" style="width: 100%;height: 100%;"></image>
- <view style="z-index: 9;position: absolute;top: -15rpx;right: -15rpx;"
- @click="removeImg(index)">
- <image src="../static/gb.png" style="width:50rpx;height:50rpx;"></image>
- </view>
-
- </view>
- </view>
- </view>
- </view>
- <view class="margin-top-sm" @click="addImage()" v-if="drivingLicence.length<=5">
- <view style="width: 200rpx;height: 200rpx;background: #f4f5f6;border-radius: 16rpx;"
- class="flex justify-center align-center">
- <view>
- <view class="text-center">
- <image src="../static/photo.png" style="width: 65rpx;height: 55rpx;">
- </image>
- </view>
- <view class="text-center text-black">上传驾驶证</view>
- </view>
- </view>
- </view>
- </view>
- </view> -->
- </view>
- <!-- <view class=" padding bg-white margin-top " style="border-radius: 24rpx;">
-
- </view> -->
- <!-- <view class="padding bg-white radius margin-top" v-if="!disabled">
- <view class="text-bold" style="color: #3699FF;">缴纳保证金</view>
- <view class="flex justify-between margin-top-sm">
- <view class="text-gray">满足订单量及好评率即可申请退还保证金</view>
- <view class="text-bold" style="color:#F1413D;">¥{{money}}</view>
- </view>
- </view> -->
- <view class=" margin-top footer text-xxl" v-if="!disabled">
- <text @tap="isShowAgree" class="cuIcon"
- :class="showAgree?'cuIcon-radiobox':'cuIcon-round'">同意并接受</text>
- <!-- 协议地址 -->
- <navigator url="/my/setting/sijixieyi" style="color: #3699FF;" open-type="navigate">《师傅入驻协议 》
- </navigator>
- </view>
- <view class=" margin-top footer text-xxl" v-if="disabled">
- 查看
- <navigator url="/my/setting/sijixieyi" style="color: #3699FF;" open-type="navigate">《师傅入驻协议 》
- </navigator>
- </view>
- <view style="height: 120rpx;"></view>
- </view>
- <view class="align-center padding-lr" v-if="!disabled"
- style="position: fixed;bottom: 0;width: 100%;height: 120rpx;z-index: 99;">
- <!-- <view class="">
- <text class="text-lg text-bold text-black">支付:</text>
- <text style="color: #F1413D;">¥{{money}}</text>
- </view> -->
- <view>
- <u-button v-if="!disabled" @click="submit" class="" :custom-style="customStyle" shape="circle"
- :hair-line="false">确认认证</u-button>
- </view>
- </view>
- <u-picker v-model="show" mode="time" @confirm="confirm"></u-picker>
- <u-popup v-model="showpay" mode="bottom">
- <view class="popup_pay">
- <view class="bg margin-top padding-lr radius">
- <view style="padding: 0 20upx;margin-top: 36rpx;">
- <view
- style="display: flex;height: 100upx;align-items: center;padding: 20upx 0;justify-content: center;"
- v-for="(item,index) in openLists" :key='index'>
- <image :src="item.image" style="width: 55upx;height: 55upx;border-radius: 50upx;">
- </image>
- <view style="font-size: 30upx;margin-left: 20upx;width: 70%;">
- {{item.name}}
- </view>
- <radio-group name="openWay" style="margin-left: 45rpx;" @tap='selectWay(item)'>
- <label class="tui-radio">
- <radio color="#3699FF" :checked="openWay == item.id ? true : false" />
- </label>
- </radio-group>
- </view>
- </view>
- </view>
- <view class="pay_btns" @click="pay()">确认支付</view>
- </view>
- </u-popup>
- </view>
- <view v-if="shangxian === '是'">
- <view style="line-height: 26px;padding: 32upx;" class="home1">
- <view style="font-size: 28upx;" v-html="content"></view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import configdata from '@/common/config.js';
- import { waitForGlobalImages } from '@/utils/globalImageLoader'
- export default {
- data() {
- return {
- content: '',
- form: {
- driverName: '',
- driverColor: '',
- driverPlate: '',
- driverBrand: '',
- auditContent:'',
- // identityCardNumber: '', //证件号码
- dateBirth: '', //出生日期
- frontIdentityCard: '', //身份证正面
- backIdentityCard: '', //身份证反面
- drivingLicence: '', //驾驶证
- drivingYears: '', //驾龄
- drivingLicense: '', //行驶证
- driverLicense: '', //驾驶证
- checkCertificationMessage: '',
- userType: 2,
- province: '', // 接单省
- city: '', // 接单市
- district: '', // 接单区
- },
- drivingLicence: [],
- lableStyle: {
- color: '#000',
- fontSize: '28upx',
- fontWeight: 600,
- },
- customStyle: {
- backgroundColor: '#2D8FFE',
- color: '#FFFFFF',
- border: 0,
- width: '686rpx'
- },
- btnStyle: {
- backgroundColor: '#3699FF',
- color: '#FFFFFF',
- },
- money: 0,
- showAgree: false, //协议是否选择
- // sessionkey: '',
- shangxian: '',
- showpay: false,
- openWay: 1,
- openLists: [],
- indentNumber: '',
- disabled: false,
- show: false,
- status: -1,
- cityqu: '',
- latitude: '',
- longitude: '',
- globalImages: '',
- }
- },
- onLoad() {
- waitForGlobalImages().then((path) => {
- console.log('✅ 全局图片路径:', path)
- this.globalImages = path
- })
- this.shangxian = uni.getStorageSync('shangxian')
- if (this.shangxian != '是') {
- uni.setNavigationBarTitle({
- title: '司机入驻'
- })
- } else {
- uni.setNavigationBarTitle({
- title: '关于我们'
- })
- this.$Request.getT('/app/userinfo/userAgreement').then(res => {
- if (res.code == 0) {
- this.content = res.data.value;
- // this.tit = res.data.min
- }
- });
- }
- // #ifdef MP-WEIXIN
- this.openLists = [{
- id: 1,
- image: '../../static/image/icon_weixin.png',
- name: '微信'
- }]
- // #endif
- // #ifdef H5
- let ua = navigator.userAgent.toLowerCase();
- if (ua.indexOf('micromessenger') !== -1) {
- //公众号是否自动登录 416
- this.$Request.get('/app/common/type/416').then(res => {
- if (res.data && res.data.value && res.data.value == '是') {
- this.openLists = [{
- id: 2,
- image: '../../static/image/zhifubao.png',
- name: '支付宝'
- }, {
- id: 1,
- image: '../../static/image/icon_weixin.png',
- name: '微信'
- }];
- this.openWay = 2;
- } else {
- this.openLists = [{
- id: 2,
- image: '../../static/image/zhifubao.png',
- name: '支付宝'
- }];
- this.openWay = 1;
- }
- })
- } else {
- this.openLists = [{
- id: 2,
- image: '../../static/image/zhifubao.png',
- name: '支付宝'
- }];
- this.openWay = 1;
- }
- // #endif
- // #ifdef APP-PLUS
- this.openLists = [{
- id: 1,
- image: '../../static/image/icon_weixin.png',
- name: '微信'
- },
- {
- id: 2,
- image: '../../static/image/zhifubao.png',
- name: '支付宝'
- }
- ]
- // #endif
- this.getRZmoney()
- this.getUserInfo()
- // this.sessionkey = this.$queue.getData("sessionkey");
- },
- methods: {
- openMap() {
- let that = this
- uni.chooseLocation({
- success: function(res) {
- console.log('位置名称:' + res.name);
- console.log('详细地址:' + res.address);
- console.log('纬度:' + res.latitude);
- console.log('经度:' + res.longitude);
- that.latitude = res.latitude
- that.longitude = res.longitude
- that.selectCity(that.longitude, that.latitude);
- }
- });
- },
- //设置地图标记
- selectCity(longitude, latitude) {
- this.$Request.getT('/app/Login/selectCity?lat=' + latitude + '&lng=' + longitude).then(res => {
- if (res.code == 0) {
- this.form.city = res.data.city ? res.data.city : res.data.province
- this.form.county = res.data.district
- this.form.province = res.data.province
- this.cityqu = this.form.province + ' ' + this.form.city + ' ' + this.form.county
- } else {
- uni.showToast({
- title: res.msg,
- icon: 'none'
- })
- }
- })
- },
- confirm(e) {
- // console.log(e,'========')
- this.form.dateBirth = e.year + '-' + e.month + '-' + e.day
- },
- removeImg(index) {
- this.drivingLicence.splice(index, 1)
- },
- isShowAgree() {
- this.showAgree = !this.showAgree
- },
- getRZmoney() {
- this.$Request.get("/app/common/type/261").then(res => {
- if (res.code == 0) {
- this.money = res.data.value
- // this.form.cashDeposit = res.data.value
- }
- });
- },
- selectWay: function(item) {
- this.openWay = item.id;
- },
- submit() {
- let that = this
- // console.log(that.form)
- if (!that.form.driverName) {
- uni.showToast({
- title: '请输入真实姓名',
- icon: 'none',
- duration: 1000
- })
- return;
- }
- // if (!that.form.identityCardNumber) {
- // uni.showToast({
- // title: '请输入身份证号',
- // icon: 'none',
- // duration: 1000
- // })
- // return;
- // }
- if (!that.form.dateBirth) {
- uni.showToast({
- title: '请选择出生日期',
- icon: 'none',
- duration: 1000
- })
- return;
- }
- if (!that.form.drivingYears) {
- uni.showToast({
- title: '请填写驾龄',
- icon: 'none',
- duration: 1000
- })
- return;
- }
- // if (!that.cityqu) {
- // uni.showToast({
- // title: '请选择省市区',
- // icon: 'none',
- // duration: 1000
- // })
- // return;
- // }
- if (!that.form.driverBrand) {
- uni.showToast({
- title: '请填写车辆品牌',
- icon: 'none',
- duration: 1000
- })
- return;
- }
- if (!that.form.driverPlate) {
- uni.showToast({
- title: '请填写车牌号',
- icon: 'none',
- duration: 1000
- })
- return;
- }
- if (!that.form.driverColor) {
- uni.showToast({
- title: '请填写车辆颜色',
- icon: 'none',
- duration: 1000
- })
- return;
- }
- if (!that.form.frontIdentityCard) {
- uni.showToast({
- title: '请上传身份证正面',
- icon: 'none',
- duration: 1000
- })
- return;
- }
- if (!that.form.backIdentityCard) {
- uni.showToast({
- title: '请上传身份证反面',
- icon: 'none',
- duration: 1000
- })
- return;
- }
-
- if (!that.form.drivingLicense) {
- uni.showToast({
- title: '请上传行驶证',
- icon: 'none',
- duration: 1000
- })
- return;
- }
- if (!that.form.driverLicense) {
- uni.showToast({
- title: '请上传驾驶证',
- icon: 'none',
- duration: 1000
- })
- return;
- }
- if (!that.showAgree) {
- uni.showToast({
- title: '请勾选师傅入驻协议',
- icon: 'none',
- duration: 1000
- })
- return;
- }
- // that.showpay = true
- let userId = this.$queue.getData('userId');
- that.$Request.postJson('/app/driver/insertDriver?userId=' + userId,that.form).then(res =>{
- uni.hideLoading();
- if(res.code == 0){
- that.$queue.showToast('提交成功!')
- setTimeout(d =>{
- uni.navigateBack();
- },1500)
- }else{
- that.$queue.showToast(res.msg);
- }
- });
- },
- getUserInfo() {
- let userId = this.$queue.getData('userId');
- this.$Request.getT("/app/driver/selectDriverByUserId?userId=" + userId).then(res => {
- if (res.code == 0 && res.data) {
- this.form.driverName = res.data.driverName ? res.data.driverName : ''
- // this.form.identityCardNumber = res.data.identityCardNumber ? res.data.identityCardNumber : ''
- this.form.auditContent = res.data.auditContent ? res.data.auditContent : ''
- this.form.dateBirth = res.data.dateBirth ? res.data.dateBirth : ''
- this.form.backIdentityCard = res.data.backIdentityCard ? res.data.backIdentityCard : ''
- this.form.frontIdentityCard = res.data.frontIdentityCard ? res.data.frontIdentityCard : ''
-
-
- this.form.drivingLicense = res.data.drivingLicense ? res.data.drivingLicense : ''
- this.form.driverLicense = res.data.driverLicense ? res.data.driverLicense : ''
-
- this.form.driverColor = res.data.driverColor ? res.data.driverColor : ''
- this.form.driverPlate = res.data.driverPlate ? res.data.driverPlate : ''
- this.form.driverBrand = res.data.driverBrand ? res.data.driverBrand : ''
- this.form.drivingYears = res.data.drivingYears ? res.data.drivingYears : ''
- this.form.drivingLicence = res.data.drivingLicence ? res.data.drivingLicence : ''
- if (res.data.drivingLicence) {
- this.drivingLicence = res.data.drivingLicence.split(',')
- }
- this.form.city = res.data.city ? res.data.city : res.data.province
- this.form.county = res.data.district ? res.data.district : ''
- this.form.province = res.data.province ? res.data.province : ''
- // if (this.form.city) {
- // this.cityqu = this.form.province + ' ' + this.form.city + ' ' + this.form.county
- // }
- if (res.data.status == 1 || res.data.status == 2) {
- this.disabled = true
- }
- // if (res.data.status == 2) {
- // this.form.checkCertificationMessage = res.data.checkCertificationMessage ? res.data
- // .checkCertificationMessage : ''
- // }
- this.status = res.data.status
- //状态 1待审核 2已通过 3已拒绝
- }
- });
- },
- addImages(e) {
- uni.chooseImage({
- count: 1,
- sourceType: ['album', 'camera'],
- success: res => {
- for (let i = 0; i < 1; i++) {
- this.$queue.showLoading("上传中...");
- uni.uploadFile({ // 上传接口
- // url: this.config("APIHOST1") + '/alioss/upload', //真实的接口地址
- url: 'https://shunfengcheshop.xianmxkj.com/sqx_fast/alioss/upload',
- filePath: res.tempFilePaths[i],
- name: 'file',
- success: (uploadFileRes) => {
- console.log(uploadFileRes)
- if (e == 1) {
- this.form.frontIdentityCard = JSON.parse(uploadFileRes
- .data).data
- } else if (e == 2) {
- this.form.backIdentityCard = JSON.parse(uploadFileRes
- .data).data
- } else if (e == 3) {
- this.form.drivingLicense = JSON.parse(uploadFileRes
- .data).data
- } else if(e == 4){
- this.form.driverLicense = JSON.parse(uploadFileRes
- .data).data
- }
- uni.hideLoading();
- }
- });
- }
- }
- })
- },
- addImage() {
- let count = 6 - this.drivingLicence.length
- uni.chooseImage({
- count: count,
- sourceType: ['album', 'camera'],
- success: res => {
- for (let i = 0; i < res.tempFilePaths.length; i++) {
- this.$queue.showLoading("上传中...");
- uni.uploadFile({ // 上传接口
- url: this.config("APIHOST1") + '/alioss/upload', //真实的接口地址
- filePath: res.tempFilePaths[i],
- name: 'file',
- success: (uploadFileRes) => {
- // console.log(uploadFileRes)
- this.drivingLicence.push(JSON.parse(uploadFileRes.data).data)
- uni.hideLoading();
- }
- });
- }
- }
- })
- },
- config: function(name) {
- var info = null;
- if (name) {
- var name2 = name.split("."); //字符分割
- if (name2.length > 1) {
- info = configdata[name2[0]][name2[1]] || null;
- } else {
- info = configdata[name] || null;
- }
- if (info == null) {
- let web_config = cache.get("web_config");
- if (web_config) {
- if (name2.length > 1) {
- info = web_config[name2[0]][name2[1]] || null;
- } else {
- info = web_config[name] || null;
- }
- }
- }
- }
- return info;
- },
- pay() {
- if (this.openWay == 0) {
- this.$queue.showToast('请选择支付方式!')
- return;
- }
- this.form.drivingLicence = this.drivingLicence
- this.form.drivingLicence = this.form.drivingLicence.toString()
- if (this.openWay == 1) {
- console.log('微信')
- // #ifdef APP-PLUS
- // 微信APP支付 根据订单id获取支付信息
- this.$Request.postJson("/app/wxPayRider/appRiderCertification", this.form).then(res => {
- console.log(JSON.stringify(res), '微信支付信息')
- this.isCheckPay(res.code, 'wxpay', JSON.stringify(res.data));
- });
- // #endif
- // #ifdef H5
- // 微信APP支付 根据订单id获取支付信息
- this.$Request.postJson("/app/wxPayRider/wxPayMpRiderCertification", this.form).then(res => {
- console.log(JSON.stringify(res), '微信支付信息')
- this.callPay(res.data);
- });
- // #endif
- // #ifdef MP-WEIXIN
- let that = this
- that.$Request.postJson("/app/wxPayRider/wxPayJsApiRiderCertification", that.form).then(res => {
- if (res.code == 0) {
- uni.requestPayment({
- provider: 'wxpay',
- timeStamp: res.data.timestamp,
- nonceStr: res.data.noncestr,
- package: res.data.package,
- signType: res.data.signType,
- paySign: res.data.sign,
- success: function(res) {
- console.log(res)
- uni.hideLoading();
- uni.showToast({
- title: '实名认证提交成功',
- icon: 'none'
- });
- setTimeout(function() {
- uni.navigateBack(1)
- }, 1000)
- },
- fail: function(err) {
- console.log('fail:' + JSON.stringify(err));
- uni.hideLoading();
- that.$queue.showToast('支付失败');
- }
- });
- } else {
- uni.showToast({
- title: res.msg,
- icon: 'none'
- })
- }
- });
- // #endif
- } else {
- // APP支付宝支付
- // #ifdef H5
- this.form.payType = 5
- this.$Request.postJson('/app/aliPay/aliPayRiderCertification', this.form).then(
- res => {
- if (res.code == 0) {
- const div = document.createElement('div')
- div.innerHTML = res.data //此处form就是后台返回接收到的数据
- document.body.appendChild(div)
- document.forms[0].submit()
- } else {
- uni.showToast({
- icon: 'none',
- title: '支付失败!'
- });
- }
- });
- // #endif
- // #ifdef APP
- this.form.payType = 4
- this.$Request.postJson("/app/aliPay/aliPayRiderCertification", this.form).then(res => {
- console.log(JSON.stringify(res), '支付宝支付信息')
- this.isCheckPay(res.code, 'alipay', res.data)
- });
- // #endif
- }
- },
- callPay: function(response) {
- if (typeof WeixinJSBridge === "undefined") {
- if (document.addEventListener) {
- document.addEventListener('WeixinJSBridgeReady', this.onBridgeReady(response), false);
- } else if (document.attachEvent) {
- document.attachEvent('WeixinJSBridgeReady', this.onBridgeReady(response));
- document.attachEvent('onWeixinJSBridgeReady', this.onBridgeReady(response));
- }
- } else {
- this.onBridgeReady(response);
- }
- },
- onBridgeReady: function(response) {
- let that = this;
- // if (!response.package) {
- // return;
- // }
- console.log(response, 111111)
- WeixinJSBridge.invoke(
- 'getBrandWCPayRequest', {
- "appId": response.appid, //公众号名称,由商户传入
- "timeStamp": response.timestamp, //时间戳,自1970年以来的秒数
- "nonceStr": response.noncestr, //随机串
- "package": response.package,
- "signType": response.signType, //微信签名方式:
- "paySign": response.sign //微信签名
- },
- function(res) {
- console.log(res, '/*-/*-/*-')
- if (res.err_msg === "get_brand_wcpay_request:ok") {
- // 使用以上方式判断前端返回,微信团队郑重提示:
- //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
- uni.showLoading({
- title: '支付成功'
- });
- setTimeout(function() {
- uni.hideLoading();
- uni.navigateBack()
- }, 1000);
- } else {
- uni.hideLoading();
- }
- WeixinJSBridge.log(response.err_msg);
- }
- );
- },
- isCheckPay(status, name, order) {
- if (status == 0) {
- this.setPayment(name, order);
- } else {
- uni.hideLoading();
- uni.showToast({
- title: '支付信息有误',
- icon: 'none'
- });
- }
- },
- setPayment(name, order) {
- console.log(name, '*-*-*', order)
- uni.requestPayment({
- provider: name,
- orderInfo: order, //微信、支付宝订单数据
- success: function(res) {
- console.log(res)
- uni.hideLoading();
- uni.showLoading({
- title: '支付成功'
- });
- setTimeout(function() {
- uni.navigateBack()
- }, 1000);
- },
- fail: function(err) {
- console.log(err)
- uni.hideLoading();
- },
- complete() {
- uni.hideLoading();
- }
- });
- },
- }
- }
- </script>
- <style lang="less">
- page {
- background: #F5F5F5;
- }
- .footer {
- /* // padding-left: 140upx; */
- /* justify-content: center; */
- margin-top: 32upx;
- font-size: 24upx;
- color: #666666;
- display: flex;
- // text-align: center;
- // align-items: center;
- }
- /* 支付弹框 */
- .popup_pay {
- width: 100%;
- }
- .pay_btns {
- width: 90%;
- margin: 0 auto 40rpx;
- text-align: center;
- background: #3699FF;
- height: 80rpx;
- border-radius: 16rpx;
- color: #ffffff;
- line-height: 80rpx;
- margin-top: 20rpx;
- }
- </style>
|