123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- const utils = require('../../utils/util')
- const form = require('../../utils/formValidation')
- const util = require('../../utils/util.js');
- const app = getApp();
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- values:{
- repairsBy:'',
- repairsPhone:'',
- expressCompany:'',
- expressSn:'',
- area:'',
- address:'',
- deviceId:'',
- deviceSn:'',
- repairsRemark:''
- },
- region: [],
- expressCompany:[{
- text:"韵达快递",
- value:"韵达快递"
- },{
- text:"天天快递",
- value:"天天快递"
- },{
- text:"申通快递",
- value:"申通快递"
- },{
- text:"圆通速递",
- value:"圆通速递"
- },{
- text:"德邦物流",
- value:"德邦物流"
- },{
- text:"百世汇通",
- value:"百世汇通"
- },{
- text:"顺丰速运",
- value:"顺丰速运"
- },{
- text:"京东物流",
- value:"京东物流"
- },{
- text:"中通速递",
- value:"中通速递"
- },{
- text:"国通快递",
- value:"国通快递"
- },{
- text:"极兔快递",
- value:"极兔快递"
- }],
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- },
- bindPickerChange: function (e) {
- console.log(e)
- var item = this.data.expressCompany[e.detail.value]
- console.log(item)
- this.setData({
- ['values.expressCompany']: item.value,
- })
- },
- scanCodeEvent() {
- var that = this;
- wx.scanCode({
- onlyFromCamera: true, // 只允许从相机扫码
- success(res) {
- console.log("扫码成功:" + JSON.stringify(res))
- that.setData({
- ['values.deviceSn']: res.result
- })
- }
- })
- },
- formSubmit: function(e) {
- //表单规则
- let rules = [{
- name: "repairsBy",
- rule: ["required", "isChinese"],
- msg: ["请选择负责人姓名", "姓名必须全部为中文"]
- }, {
- name: "repairsPhone",
- rule: ["required", "isMobile"],
- msg: ["请输入手机号", "请输入正确的手机号"]
- }];
- //进行表单检查
- let formData = e.detail.value;
- let checkRes = form.validation(formData, rules);
- console.log(this.data.values)
- if (!checkRes) {
- // wx.showToast({
- // title: "验证通过!",
- // icon: "none"
- // });
- var that = this
-
- util.request(util.api.addRepairs, that.data.values, "POST", false, true,app.globalData.token).then((res)=>{
- console.log(that.data.values)
- if (res.code == 200) {
- wx.navigateTo({
- url: '/pages/repairs/index',
- })
- }
- }).catch((res) => {})
- } else {
- wx.showToast({
- title: checkRes,
- icon: "none"
- });
- }
- },
- formReset: function(e) {
- console.log("清空数据")
- },
- bindRegionChange: function (e) {
- console.log(e.detail.value)
- console.log(e.detail.code)
- this.setData({
- region: e.detail.value
- })
- this.data.values.area = this.data.region.join(" ")
- },
- inputedit: function (e) {
- let _this = this;
- let dataset = e.currentTarget.dataset;
- let value = e.detail.value;
- let name = dataset.name;
- _this.data[name] = value;
- _this.setData({
- [name]: _this.data[name]
- });
- },
- })
|