123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524 |
- const util = require('../../../utils/util.js');
- const app = getApp();
- Page({
- data: {
- reasonData: [],
- current: 1,
- imgPath: util.config.imgPath,
- datas: {},
- reason: '',
- showtext: false,
- mask: false,
- refundBack: '',
- refundpwd: '',
- orderid: '',
- status: '',
- groupId: '',
- reasonList: [],
- reasonIndex: 0,
- defaultText: "请选择 >",
- // 控制sku
- showSku: false,
- refundShow: false,
- oid: "",
- orderInfo: {},
- codeShow: false,
- query: {
- orderid: '',
- otype: 0,
- presellStatus: 0
- },
- showGoodsRecom: false,
- index: 0,
- changeMeal_oid: "",
- type: 0,
- // 支付宝户号绑定内容
- AlipayNum: "",
- // 支付宝账号绑定内容
- accountNum: "",
- // 银行卡户名
- carName: "",
- // 银行名称
- bankName: "",
- // 银行卡号
- BankcardNo: "",
- // 银行开户行
- Bankofdeposit: "",
- password: ''
- },
- isOK() {
- this.setData({
- codeShow: false
- });
- },
- // 二维码弹框
- showCode() {
- console.log("执行");
- this.setData({
- showSku: false,
- codeShow: true
- });
- },
- // 换场次中点击退款条例
- showFund() {
- this.setData({
- showSku: false,
- refundShow: true,
- type: this.data.orderInfo.refundRule
- });
- },
- changedeposit(e) {
- this.setData({
- Bankofdeposit: e.detail.value
- });
- },
- ChangeBankcardNo(e) {
- this.setData({
- BankcardNo: e.detail.value
- });
- },
- closeRefund() {
- this.setData({
- refundShow: false
- });
- },
- changeName(e) {
- this.setData({
- bankName: e.detail.value
- });
- },
- changebankName(e) {
- this.setData({
- carName: e.detail.value
- });
- },
- changeaccount(e) {
- this.setData({
- accountNum: e.detail.value
- });
- },
- changeAlipay(e) {
- // console.log(e.detail.value);
- this.setData({
- AlipayNum: e.detail.value
- });
- },
- showProp() {
- // if(this.data.orderInfo.refundRule==1){
- // this.data.type=this.data.orderInfo.refundRule
- // }
- // console.log(this.data.orderInfo);
- console.log(this.data.orderInfo.refundRule);
- this.setData({
- refundShow: true,
- type: this.data.orderInfo.refundRule
- // type:3
- });
- },
- // 关闭弹框
- closeSku() {
- this.setData({
- showSku: false,
- changeMeal_oid: ''
- });
- },
- // 点击换场次
- confirmChange(e) {
- console.log(this.data.orderInfo);
- let that = this,
- data = {};
- data.newAlipayId = e.detail ? e.detail : '';
- data.oid = that.data.changeMeal_oid;
- console.log(data);
- util.ajax({
- func: "v2/order/getRefundPriceByOid",
- data: {
- oid: that.data.info.subOrders[that.data.index].oid
- }
- }, function (res) {
- data.priceInfo = that.data.orderInfo;
- data.password = that.data.password;
- console.log(data);
- if (res.code == 0) {
- util.ajax({
- func: "v2/order/change/audit",
- data,
- method: 'POST',
- load: false
- }, function (res) {
- if (res.code == 0) {
- util.showTips('已发起申请,请耐心等待宝大大审核~');
- that.setData({
- showSku: false,
- changeMeal_oid: ''
- });
- that.getData1();
- } else {
- console.log(data);
- util.showTips(res.reason);
- }
- });
- } else if (res.code == -10) {
- util.showTips('不满足更换场次要求,请联系宝大大处理');
- } else {
- console.log(data);
- util.showTips(res.reason);
- }
- });
- },
- // 退款换场次
- changeMeals(e) {
- console.log(this.data.info.subOrders[this.data.index]);
- let status = this.data.info.subOrders[this.data.index].changeStatus,
- oid = this.data.info.subOrders[this.data.index].oid;
- if (status == 1) {
- util.showTips('已提交申请,请耐心等待宝大大审核~');
- return false;
- } else {
- let that = this;
- this.OrderInfo(oid);
- this.setData({
- showSku: true,
- changeMeal_oid: oid
- });
- console.log(this.data.changeMeal_oid);
- }
- },
- // 获取换场次信息
- getData1(val) {
- let that = this;
- let data = {};
- if (!util.isEmpty(that.data.orderid)) {
- data.orderid = that.data.orderid;
- }
- if (!util.isEmpty(val || that.data.presellStatus)) {
- data.presellStatus = val || that.data.presellStatus;
- }
- if (!util.isEmpty(that.data.otype)) {
- data.otype = that.data.otype;
- }
- console.log(data);
- util.ajax({
- func: "v2/order/detail",
- data,
- load: false
- }, function (res) {
- console.log(res);
- if (res.code == 0) {
- let datas = res.data;
- datas.timeContrast = util.timeContrast(datas.stopBuy);
- if (!util.isEmpty(datas.mailAddress)) {
- var info = datas.mailAddress.split(" ");
- datas.mail = {};
- datas.mail.name = info[0] || "";
- datas.mail.postMobile = info[1] || "";
- datas.mail.province = info[2] || "";
- datas.mail.address = datas.mail.province.replace("/", "") + info[3];
- }
- if (datas.comment) {
- datas.comment.tag = datas.comment.content.match(/#([^#]+)#/g) ? datas.comment.content.match(/#([^#]+)#/g).join("") : '';
- datas.comment.content = datas.comment.content.replace(/#([^#]+)#/g, "").replace(/<br\/>/g, '\n');
- if (datas.comment.additionalComment.content) {
- datas.comment.additionalComment.content = datas.comment.additionalComment.content.replace(/<br\/>/g, '\n');
- }
- }
- that.nps();
- if (datas.saleTime && datas.presellPaymentDeadline) {
- datas.startTime = util.formatDate(util.formatUnixtimestamp(datas.saleTime), 'MM月dd日 hh:mm', false);
- datas.endTime = util.formatDate(util.formatUnixtimestamp(datas.presellPaymentDeadline), 'MM月dd日 hh:mm', false);
- }
- let num = 0,
- length = datas.groupinfo.discount && !util.isEmpty(datas.groupinfo.discount.users) ? datas.groupinfo.discount.users.length : 0;
- if (length > 0) {
- datas.groupinfo.discount.users.forEach((el) => {
- num = el.status == 4 ? num++ : num;
- if (el.status == 4) {
- num++;
- }
- that.setData({
- iconView: num == 0 ? false : true
- });
- });
- }
- that.setData({
- info: datas
- });
- // console.log(that.data.info.subOrders[that.data.index].changeStatus);
- that.getGoodsRecommend();
- if (datas.groupinfo.gstatus == 0 && datas.groupinfo.discount && datas.groupinfo.discount.status == 0 && datas.groupinfo.discount.deadline > 0) {
- that.data.info.groupinfo.discount.deadline = that.data.info.groupinfo.discount.deadline - new Date().getTime();
- that.updateTime();
- }
- } else
- util.showTips(res.reason);
- });
- },
- // 默认评价弹窗
- nps() {
- let that = this,
- newDate = util.getNowFormatDate('yyyy-MM-dd hh:mm:ss');
- let npsData = tt.getStorageSync("nps") || {
- num: 0,
- oldDate: newDate,
- timesSec: newDate
- };
- if (npsData.num < util.config.npsNum && util.datedifference(newDate, npsData.timesSec, true) > 3600 || util.isObjEmpty(npsData)) {
- util.ajax({
- func: "v2/order/reviews/one",
- load: false
- }, function (res) {
- if (res.code == 0 && !util.isObjEmpty(res.data)) {
- that.setData({
- npsOptons: res.data,
- npsStatus: true
- });
- npsData.num += 1;
- npsData.timesSec = newDate;
- tt.setStorageSync("nps", npsData);
- }
- });
- }
- },
- getGoodsRecommend() {
- let that = this;
- util.getGoodsRecommend(this.data.info.aid).then((res) => {
- that.setData({
- showGoodsRecom: res
- });
- });
- },
- // 获取订单信息
- OrderInfo(oid) {
- console.log(this.data.oid);
- let that = this;
- util.ajax({
- func: "v2/order/getRefundPriceByOid",
- data: {
- "oid": that.data.oid
- }
- }, function (res) {
- console.log(res);
- if (res.code == 0) {
- that.setData({
- orderInfo: res.data,
- changeMeal_oid: oid
- });
- } else if (res.code == -10) {
- util.showTips('不满足更换场次要求,请联系宝大大处理');
- that.setData({
- showSku: false,
- changeMeal_oid: oid
- });
- } else {
- util.showTips(res.reason);
- }
- });
- },
- onLoad(options) {
- console.log(options);
- this.setData({
- index: options.index,
- oid: options.oid,
- refundpwd: options.refundpwd,
- orderid: options.orderid,
- status: options.refundStatus,
- groupId: options.groupid || '',
- password: options.refundpwd
- });
- if (options.atype != "1") {
- this.OrderInfo();
- } else {
- this.setData({
- atype: options.atype
- });
- }
- let reasonData = [],
- current = 1;
- if (this.data.status == 15) {
- current = 4;
- }
- this.setData({
- current
- });
- this.getData();
- },
- onShow() {},
- // 切换退款原因
- changeReason(e) {
- console.log(e.detail.value);
- console.log(this.data.reasonData[e.detail.value].type == 0);
- if (this.data.reasonData[e.detail.value].type == 0) {
- this.setData({
- showtext: true
- });
- } else {
- this.setData({
- showtext: false
- });
- }
- this.data.reasonIndex = e.detail.value;
- this.setData({
- reasonIndex: this.data.reasonIndex,
- defaultText: this.data.reasonList[this.data.reasonIndex]
- });
- },
- getData() {
- let that = this;
- let current = 0;
- util.ajax({
- func: "v2/order/detail",
- data: {
- "orderid": that.data.orderid,
- "otype": 0,
- "password": that.data.refundpwd || ""
- }
- }, function (res) {
- if (res.code == 0) {
- let reasonData = [];
- if (res.data.atype == '1') { //电商
- reasonData = [{
- type: 5,
- txt: '不喜欢/不想要'
- },
- {
- type: 6,
- txt: '质量问题'
- },
- {
- type: 0,
- txt: '其他原因'
- }
- ];
- } else {
- if (that.data.status == 15) {
- reasonData = [{
- type: 4,
- txt: '候补退款'
- }], current = 4;
- } else {
- reasonData = [{
- type: 1,
- txt: '行程有变'
- },
- {
- type: 2,
- txt: '买多了/买错了'
- },
- {
- type: 3,
- txt: '孩子突发身体原因'
- },
- {
- type: 0,
- txt: '其他原因'
- }
- ];
- }
- }
- reasonData.forEach((item) => {
- console.log(item);
- that.data.reasonList.push(item.txt);
- });
- that.setData({
- datas: res.data,
- reasonData,
- current: reasonData[0].type,
- reasonList: that.data.reasonList
- });
- console.log(that.data.defaultText, 7)
- }
- });
- },
- backBtn() {
- tt.redirectTo({
- url: '/pages/order/index/order?otype=2'
- });
- },
- confirm(e) {
- console.log(e);
- this.setData({
- reason: e.detail.value
- });
- },
- bindreason(e) {
- console.log(e);
- this.setData({
- current: e.currentTarget.dataset.type
- });
- },
- img() {
- this.data.datas.logo = '/images/noimg.png';
- this.setData({
- datas: this.data.datas
- });
- },
- refundRequest() {
- let that = this,
- current = this.data.current;
- console.log(current, 78787);
- if (this.data.defaultText == "请选择 >") {
- util.showTips("请选择退款原因");
- return false;
- }
- if (this.data.showtext == true && util.isEmpty(this.data.reason)) {
- util.showTips("请填写退款原因");
- return false;
- }
- util.ajax({
- func: "tiktok/order/preRefund/detail",
- data: {
- "oid": that.data.oid
- }
- }, function (res) {
- if (res.code == 0) {
- tt.applyRefund({
- refundInfo: {
- reason: [that.data.defaultText], // 退款理由 必填
- note: that.data.reason, // 备注 非必填
- },
- outOrderNo: that.data.datas.outTradeNo, // 外部订单号 必填
- itemOrderList: [{
- itemOrderId: res.data.itemOrderList[0].itemOrderId
- }, ],
- callbackData: {
- reason_type: that.data.reasonIndex,
- reason: that.data.reason ? that.data.reason : that.data.defaultText,
- oid: that.data.oid,
- }, // 透传数据,开发者自定义字段 非必传
- success: successRes => {
- that.setData({
- mask: true
- });
- console.log('申请退款成功', successRes, '参数',
- 'itemOrderId:', res.data.itemOrderList[0].itemOrderId,
- 'reason:', that.data.defaultText
- );
- },
- fail: errRes => {
- const {
- errNo,
- errMsg,
- errLogId
- } = errRes;
- util.showTips(errMsg);
- console.log('申请失败', errNo, errMsg, errLogId, '参数',
- 'itemOrderId:', res.data.itemOrderList[0].itemOrderId, 'reason:', that.data.defaultText);
- },
- });
- } else {
- util.showTips(res.reason);
- }
- });
- },
- onReady() {
- }
- });
|