| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- <template>
- <view>
- <view class="top">
- <view class="title">付款给:<text>{{title}}</text></view>
- <view class="shop">{{options.merchantName ? options.merchantName : ''}}<text v-if="options.merchantName&&options.name">/</text>{{options.name ? options.name : ''}}</view>
- </view>
- <view class="con">
- <view class="tits">付款金额</view>
- <view class="money ddflex">
- <text>¥</text>
- <input v-model="money" :disabled="unEdit?true:false" type="digit" class="fflex" />
- </view>
- <view class="bz">
- <textarea v-model="remarks" placeholder="填写备注" placeholder-class="placeholder" class="bzcon"></textarea>
- </view>
- <view class="btn" @click="pays()">马上付款</view>
- <navigator :url="'/payment/paymentList/paymentList?openId=' + openId" hover-class="none" class="jilu">买单记录</navigator>
- </view>
- </view>
- </template>
- <script>
- const req = require('../../utils/request.js');
- const api = require('../../utils/api.js');
- const util = require('../../utils/util.js');
- const app = getApp();
- export default {
- data() {
- return {
- options: {},
- title: '',
- openId: '',
- money: '',
- remarks: '',
- scene: '',
- unEdit:false,//扫码带金额进来则不允许修改
- };
- },
- async onLoad(options) {
- console.log('options==', options)
- this.options = options;
- app.globalData.getCheckSessoin(json => {
- this.openId = json.openid;
- });
- await req.silenceLogin(options.userId, '');
- if(options.scene){
- this.scene = decodeURIComponent(options.scene);
- await this.loadCodeParams();
- }else{
- await this.getConfig();
- if(options.merchantId && options.merchantId != 'null' && options.merchantId != ''){
- await this.getMerchant();
- }
- if(this.options.uid){
- await this.getUserInfo();
- }
- }
- },
- onShow(){
- },
- methods: {
- getConfig() {
- var _this = this;
- return new Promise((resolve,reject)=>{
- req.getRequest('/api/config', {}, function(res) {
- _this.title = res.CONFIG_PROJECT_TITLE;
- uni.setNavigationBarTitle({
- title: _this.title + '收银台'
- })
- resolve();
- })
- })
- },
- getMerchant(){
- return new Promise((resolve,reject)=>{
- req.getRequest('/api/merchant/getMerchant',{id: this.options.merchantId},res=>{
- this.options.merchantName = res.title;
- resolve();
- })
- })
- },
- getUserInfo(){
- return new Promise((resolve,reject)=>{
- req.getRequest('/api/user/getInfo',{userId: this.options.uid},res=>{
- this.options.name = res.realName ? res.realName : res.nickName;
- resolve();
- })
- })
- },
- pays(){
- let params = {};
- var keys = unescape(this.scene).split('=');
- let apiUrl = '';
- if(keys[0] == 'id'){
- params = {
- openId: this.openId,
- money: this.money,
- id: keys[1]
- }
- if(this.remarks){
- params.note = this.remarks;
- }
- apiUrl = '/api/v3/collection/create';
- }else{
- params = {
- openId: this.openId,
- initiator: this.options.uid,
- money: this.money,
- merchantId: this.options.merchantId,
- type: this.options.type
- }
- if(this.remarks){
- params.remarks = this.remarks
- }
- apiUrl = '/api/receipt/initiateCollection';
- }
- req.postRequest(apiUrl,params,res=>{
- this.payOrder(res)
- })
- },
- payOrder(res) {
- var keys = unescape(this.scene).split('=');
- if(keys[0] == 'id'){
- req.payOrder(res, success => {
- uni.redirectTo({
- url: '/payment/success/success?openId=' + this.openId
- })
- },'payment')
- }else{
- req.receipt(res, success => {
- uni.redirectTo({
- url: '/payment/success/success?openId=' + this.openId
- })
- })
- }
-
- },
- loadCodeParams() {
- let _ts = this;
- return new Promise((resolve, reject) => {
- var keys = unescape(_ts.scene).split('=');
- let form = {
- id: keys[1]
- };
- req.getRequest('/api/v3/collection/params', form, data => {
- this.title = data.authName;
- this.options.merchantName = data.merchantName;
- this.options.name = data.userName;
- if(data.money != 0){
- this.money = data.money;
- if(data.money) this.unEdit = true
- }
- this.options.remarks = data.note ? data.note : '';
- resolve();
- });
- });
- },
- }
- };
- </script>
- <style>
- @import "./payment.css";
- </style>
|