合同小程序前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

271 lines
9.4 KiB

"use strict";
const common_vendor = require("../../common/vendor.js");
const api = require("../../api.js");
const common_assets = require("../../common/assets.js");
const _sfc_main = common_vendor.defineComponent({
data() {
return {
params: new UTSJSONObject({
pageNo: 1,
pageSize: 10,
status: ""
}),
firstFocus: false,
searchKey: "",
activeTab: "全部",
tabs: ["全部", "已生效", "已失效"],
orders: [
/* 从接口获取的数据 */
]
};
},
mounted() {
api.isToken();
common_vendor.index.showLoading({ title: "查询中..." });
setTimeout(() => {
api.list(new UTSJSONObject({ pageNo: 1, pageSize: 10 })).then((res = null) => {
for (var index = 0; index < res.result.records.length; index++) {
this.orders.push(res.result.records[index]);
}
});
common_vendor.index.hideLoading();
}, 1e3);
},
computed: {
filteredOrders() {
return this.orders.filter((item) => {
return item.custName.includes(this.searchKey) || item.custPhone.includes(this.searchKey);
});
}
},
methods: {
// 清楚搜索框信息
clear() {
this.searchKey = "";
},
// 到底部刷新
scrolltolower() {
common_vendor.index.showLoading({
title: "刷新中.."
});
api.list(this.params).then((res = null) => {
let orders = res.result.records;
for (var index = 0; index < orders.length; index++) {
this.orders.push(orders[index]);
}
common_vendor.index.hideLoading();
});
this.params.pageNo++;
},
changeStatus(status = null) {
common_vendor.index.showLoading();
this.activeTab = status;
if (status == "已生效") {
this.orders.splice(0);
this.params.status = 1;
this.params.pageNo = 1;
api.list(this.params).then((res = null) => {
let orders = res.result.records;
for (var index = 0; index < orders.length; index++) {
this.orders.push(orders[index]);
}
common_vendor.index.hideLoading();
});
} else if (status == "已失效") {
this.orders.splice(0);
this.params.status = 2;
this.params.pageNo = 1;
api.list(this.params).then((res = null) => {
for (var index = 0; index < res.result.records.length; index++) {
this.orders.push(res.result.records[index]);
}
});
common_vendor.index.hideLoading();
} else {
this.params.status = "";
this.params.pageNo = 1;
api.list(this.params).then((res = null) => {
common_vendor.index.__f__("log", "at pages/index/dingdan.uvue:146", res.result);
this.orders.splice(0);
for (var index = 0; index < res.result.records.length; index++) {
this.orders.push(res.result.records[index]);
}
common_vendor.index.hideLoading();
});
}
},
// 回退
toBack() {
let canNavBack = getCurrentPages();
if (canNavBack && canNavBack.length > 1) {
common_vendor.index.navigateBack();
} else {
history.back();
}
},
IsChinese(value = null) {
const reg = /^[\u4e00-\u9fa5]+$/gi;
return reg.test(value);
},
WhNumber(value = null) {
return /^\d+$/.test(value);
},
// 搜索处理
handleSearch() {
common_vendor.index.showLoading();
if (this.IsChinese(this.searchKey)) {
api.list(new UTSJSONObject({ custName: this.searchKey, pageNo: 1, pageSize: 10 })).then((res = null) => {
this.activeTab = "全部";
this.orders.splice(0);
let orders = res.result.records;
for (var index = 0; index < orders.length; index++) {
this.orders.push(orders[index]);
}
common_vendor.index.hideLoading();
});
} else if (this.WhNumber(this.searchKey)) {
api.list(new UTSJSONObject({ custPhone: this.searchKey, pageNo: 1, pageSize: 10 })).then((res = null) => {
this.activeTab = "全部";
this.orders.splice(0);
let orders = res.result.records;
for (var index = 0; index < orders.length; index++) {
this.orders.push(orders[index]);
}
common_vendor.index.hideLoading();
});
} else if (!this.searchKey) {
api.list(new UTSJSONObject({ pageNo: 1, pageSize: 10 })).then((res = null) => {
this.activeTab = "全部";
this.orders.splice(0);
let orders = res.result.records;
for (var index = 0; index < orders.length; index++) {
this.orders.push(orders[index]);
}
common_vendor.index.hideLoading();
});
}
},
// 复制订单号
copyorderNum(orderNum = null) {
common_vendor.index.setClipboardData({
data: orderNum,
success: () => {
common_vendor.index.showToast({ title: "复制成功" });
}
});
},
// PDF下载
downloadPDF(contractUrl = null) {
return common_vendor.__awaiter(this, void 0, void 0, function* () {
common_vendor.index.showLoading({ title: "下载中..." });
common_vendor.index.__f__("log", "at pages/index/dingdan.uvue:222", contractUrl);
common_vendor.index.downloadFile({
url: contractUrl,
success: (data) => {
common_vendor.index.__f__("log", "at pages/index/dingdan.uvue:226", data);
common_vendor.index.saveFile({
tempFilePath: data.tempFilePath,
// filePath:"内部存储/Documents/",
success: (res) => {
common_vendor.index.hideLoading();
common_vendor.index.showToast({
icon: "none",
mask: true,
title: "文件已下载,打开后请点击右上角保存!",
duration: 2e3
});
setTimeout(() => {
common_vendor.index.openDocument({
filePath: res.savedFilePath,
showMenu: true,
success: function(res2) {
}
});
}, 3e3);
}
});
},
fail: (err) => {
common_vendor.index.__f__("log", "at pages/index/dingdan.uvue:255", err);
common_vendor.index.showToast({
icon: "none",
mask: true,
title: "失败请重新下载"
});
}
});
});
}
}
});
if (!Array) {
const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
const _easycom_uni_easyinput2 = common_vendor.resolveComponent("uni-easyinput");
(_easycom_uni_icons2 + _easycom_uni_easyinput2)();
}
const _easycom_uni_icons = () => "../../uni_modules/uni-icons/components/uni-icons/uni-icons.js";
const _easycom_uni_easyinput = () => "../../uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.js";
if (!Math) {
(_easycom_uni_icons + _easycom_uni_easyinput)();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return {
a: common_vendor.p({
type: "left",
size: "30",
color: "#c2d4de"
}),
b: common_vendor.o((...args) => $options.toBack && $options.toBack(...args)),
c: common_vendor.p({
type: "search",
size: 20
}),
d: common_vendor.o($options.clear),
e: common_vendor.o(($event) => $data.searchKey = $event),
f: common_vendor.p({
inputBorder: false,
placeholder: "请输入客户姓名/客户手机号",
focus: $data.firstFocus,
modelValue: $data.searchKey
}),
g: common_vendor.o((...args) => $options.handleSearch && $options.handleSearch(...args)),
h: common_vendor.f($data.tabs, (tab, k0, i0) => {
return {
a: common_vendor.t(tab),
b: tab,
c: common_vendor.n($data.activeTab === tab ? "active" : ""),
d: common_vendor.o(($event) => $options.changeStatus(tab), tab)
};
}),
i: common_vendor.f($options.filteredOrders, (order, index, i0) => {
return common_vendor.e({
a: common_vendor.t(order.orderNum),
b: common_vendor.o(($event) => $options.copyorderNum(order.orderNum), index),
c: common_vendor.t(order.custName),
d: common_vendor.t(order.custPhone),
e: common_vendor.t(order.productName),
f: common_vendor.t(order.createTime),
g: common_vendor.t(order.saleName),
h: common_vendor.t(order.storeName),
i: order.status == 1 ? true : false
}, (order.status == 1 ? true : false) ? {
j: common_vendor.o(($event) => $options.downloadPDF(order.contractUrl), index)
} : {}, {
k: order.status == 1 ? true : false
}, (order.status == 1 ? true : false) ? {
l: common_assets._imports_0$3
} : {}, {
m: order.status == 1 ? false : true
}, (order.status == 1 ? false : true) ? {
n: common_assets._imports_1$2
} : {}, {
o: index
});
}),
j: common_vendor.sei(_ctx.virtualHostId, "scroll-view"),
k: common_vendor.o((...args) => $options.scrolltolower && $options.scrolltolower(...args))
};
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-6e742b06"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/index/dingdan.js.map