joinSeller.js 3.97 KB
// pages/customer/joinSeller.js
var util = require('../../utils/util.js')
import App from '../../utils/api';
Page({

    /**
     * 页面的初始数据
     */
    data: {
        sellername: '',
        phone: '',
        rname: '',
        map_address: '',
        pro_code: '',
        dis_code: '',
        pro_code: '',
        long: '',
        lat: '',
        region: [],
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {

    },
    submitInfo() {
        let sellername = this.data.sellername.trim();
        let phone = this.data.phone.trim();
        let rname = this.data.rname.trim();
        this.setData({
            sellername,
            phone,
            rname,
        })
        if (!sellername) {
            return util.toast('请输入店铺名称', 'none')
        }
        if (!this.data.pro_code || !this.data.city_code || !this.data.dis_code) {
            return util.toast('请选择城市', 'none')
        }
        if (!this.data.map_address) {
            return util.toast('请输入店铺地址', 'none')
        }
        if (!this.data.phone) {
            return util.toast('请输入您的电话号码', 'none')
        }
        var myreg = /^[1][3,4,5,7,8][0-9]{9}$/;
        if (!myreg.test(phone)) {
            return util.toast('手机格式不正确', 'none')
        }
        if (!this.data.rname) {
            return util.toast('请输入您的姓名', 'none')
        }
        let obj = {
            sellername,
            phone,
            rname,
            map_address: this.data.map_address,
            long: this.data.long,
            lat: this.data.lat,
            pro_code: this.data.pro_code,
            city_code: this.data.city_code,
            dis_code: this.data.dis_code,
        }
        console.log('提交信息', {
            ...obj
        });
        App.SellerVersion.SetSellerCollect({
            ...obj,
            openid: getApp().openid,
        }).then(res => {
            if (res.ret != 200) {
                return util.toast(res.msg, 'none')
            }
            wx.redirectTo({
                url: '/pages/customer/collectSeller',
            })
        })
    },
    bindRegionChange(e) {
        if (e.detail.value) {
            this.setData({
                region: e.detail.value,
                pro_code: e.detail.code[0],
                city_code: e.detail.code[1],
                dis_code: e.detail.code[2],
            })
        }
    },
    // 选择地址
    chooselocation: function () {
        var that = this;
        wx.chooseLocation({
            success: function (res) {
                console.log('选址信息', res);
                that.setData({
                    map_address: res.address,
                    long: res.longitude,
                    lat: res.latitude,
                })
            },
            fail: function (res) {
                console.log(res)
                wx.showModal({
                    title: '位置授权',
                    content: '您的位置信息需授权给一键订商户用于位置的展示',
                    confirmColor: '#199095',
                    cancelColor: '#999999',
                    success: function (res) {
                        console.log(res)
                        if (res.confirm) {
                            util.setting();
                        }
                    }
                })
            }
        })

    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },
})