123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 |
- const util = require('../../utils/util.js');
- const app = getApp()
- Page({
- data: {
- openId: wx.getStorageSync("openId"),
- id: "",
- ccNo: "",
- name: "",
- phone: "",
- content: "",
- region: ['江苏省', '南京市', '栖霞区'],
- detail: "",
- money: "",
- showEdit: true,
- click: true
- },
- onLoad: function (option) {
- this.setData({
- id: option.id,
- ccNo: option.ccNo,
- showEdit: option.alreadyAppFlag
- })
- var that = this;
- wx.request({
- url: app.globalData.serverUrl + "/application/order",
- method: "GET",
- data: {
- openId: that.data.openId,
- ccNo: that.data.ccNo
- },
- header: {
- "Content-Type": "application/x-www-form-urlencoded"
- },
- success: function (res) {
- if(res.data.code == "0000"){
- var list = res.data.data.ApplicationOrder;
-
- if(list != null){
- if(list.appStatus == 'N'){
- list.appStatusName = '未支付'
- } else if(list.appStatus == 'O'){
- list.appStatusName = '已申请'
- } else if(list.appStatus == 'S'){
- list.appStatusName = '已邮寄'
- } else if(list.appStatus == 'D'){
- list.appStatusName = '已退款'
- }
- that.setData({
- detail: list,
- showEdit: false,
- money: res.data.data.totalFee
- })
- } else {
- that.setData({
- showEdit: true,
- money: res.data.data.totalFee
- })
- }
- } else {
- wx.showToast({
- title: res.data.msg,
- icon: 'none',
- duration: 2000
- })
- }
- }
- })
- },
- //姓名
- getNameValue: function(e) {
- this.setData({
- name: e.detail.value
- })
- },
- //手机号
- getPhoneValue: function(e) {
- this.setData({
- phone: e.detail.value
- })
- },
- //详细地址
- getContentValue: function(e) {
- this.setData({
- content: e.detail.value
- })
- },
- //地区
- bindRegionChange: function (e) {
- this.setData({
- region: e.detail.value
- })
- },
- //保存并支付
- toPay: function(){
- var myreg = /^1[0-9]{10,11}$/;
- if (this.data.name == "") {
- wx.showToast({
- title: '姓名不能为空',
- icon: 'none',
- duration: 1000
- })
- return false;
- } else if (this.data.phone == "") {
- wx.showToast({
- title: '手机号不能为空',
- icon: 'none',
- duration: 1000
- })
- return false;
- } else if (!myreg.test(this.data.phone)) {
- wx.showToast({
- title: '请输入正确的手机号',
- icon: 'none',
- duration: 1000
- })
- return false;
- } else if(this.data.content == ""){
- wx.showToast({
- title: '详细地址不能为空',
- icon: 'none',
- duration: 1000
- })
- return false;
- } else {
- if(this.data.click){
- var that = this , str = "";
- that.setData({
- click:false
- })
- for(var i in that.data.region){
- if(i == that.data.region.length -1){
- str += that.data.region[i]
- } else {
- str += that.data.region[i] + " "
- }
- }
- str += that.data.content
- wx.request({
- url: app.globalData.serverUrl + "/application/orderSave",
- method: "GET",
- data: {
- openId: that.data.openId,
- ccNo: that.data.ccNo,
- initiatorName: that.data.name,
- initiatorMobile: that.data.phone,
- initiatorUserId: wx.getStorageSync("userInfo").id,
- address: str
- },
- header: {
- "Content-Type": "application/x-www-form-urlencoded"
- },
- success: function (res) {
- if(res.data.code == "0000"){
- wx.showToast({
- title: '申请成功!',
- icon: 'success',
- duration: 2000
- })
-
- var item = res.data.data;
- wx.requestPayment({
- timeStamp: item.timeStamp,
- nonceStr: item.nonceStr,
- package: item.package,
- signType: item.signType,
- paySign: item.paySign,
- success (res) {
- that.setData({
- click:true
- })
- wx.showToast({
- title: "支付成功",
- icon: 'success',
- duration: 2000
- })
- setTimeout(function() {
- wx.reLaunch({
- url: '../detail/detail?id='+ that.data.id
- })
- }, 200)
- },
- fail (res) {
- that.setData({
- click:true
- })
- wx.showToast({
- title: "支付失败",
- icon: 'none',
- duration: 2000
- })
- }
- })
- } else {
- that.setData({
- click:true
- })
- wx.showToast({
- title: res.data.msg,
- icon: 'none',
- duration: 2000
- })
- }
- },
- fail: function (res) {
- that.setData({
- click:true
- })
- wx.showToast({
- title: '提交失败!',
- icon: 'none',
- duration: 2000
- })
- }
- })
- } else {
- wx.showToast({
- title: '保存中,请勿重复提交',
- icon: 'none',
- duration: 1000
- })
- }
- }
- }
- })
|