|
- // pages/supplement/supplement.js
- const app = getApp()
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- imgUrl: app.globalData.urlStatic,//图片路径
- agreement: false,
- isAgreement: true,//是否同意协议
- jobList:[],
- jobValue:0,
- provinceArr: [],//省
- provinceValue: 0,//选中的省下标
- storeArr: [],//店铺
- storeValue: 0,//选中的店铺下标
- realname:"",
- },
-
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- app.globalData.nowPage = 2;
- if (app.globalData.openid) {
- this.loadFun();
- } else {
- app.globalData.openidSuccessFuc = this.loadFun;
- }
- },
- loadFun:function(){
- this.getJobList();
- this.getUserLocation();
- var authenticationStatus = app.globalData.authenticationStatus;
- if (authenticationStatus.realName){
- this.setData({
- realname: authenticationStatus.realName
- })
- }
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
-
- },
-
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
-
- },
-
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
-
- },
-
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
-
- },
- agreementState: function () {//协议
- this.setData({
- isAgreement: !this.data.isAgreement
- })
- },
- agreementControl: function () {
- this.setData({
- agreement: !this.data.agreement
- })
- },
- getJobList:function(){
- app.wxRequest(app.globalData.urlRoot + "userInfo/getJobList", {}, res => {
- if(res.code==200){
- this.setData({
- jobList:res.data
- })
- var authenticationStatus = app.globalData.authenticationStatus;
- if (authenticationStatus.jobId) {
- for(let i=0;i<res.data.length;i++){
- if (res.data[i].jobId == authenticationStatus.jobId){
- this.setData({
- jobValue: i,
- jobDetail: res.data[i].jobDetail
- })
- break;
- }
- }
- }
- }
- },this)
- },
- jobChange:function(e){
- this.setData({
- jobValue:e.detail.value
- })
- },
- getUserLocation: function (e) {
- wx.getLocation({
- type: 'gcj02', //wgs84
- success: (res) => {
- this.getDistributorList(res.longitude, res.latitude);
- },
- fail: (res) => {
- this.getDistributorList("", "");
- }
- })
- },
- getDistributorList: function (longitude, latitude) {//获取经销商列表
- app.wxRequest(app.globalData.urlRoot + "agent/getAgentList", { longitude: longitude, latitude: latitude}, res => {
- if (res.code == 200) {
- this.setData({
- provinceArr: res.data.list,
- storeArr: res.data.list[res.data.nearData.provinceIndex].children,
- provinceValue: res.data.nearData.provinceIndex,
- storeValue: res.data.nearData.cityIndex
- })
- var authenticationStatus = app.globalData.authenticationStatus;
- if (authenticationStatus.city) {
- for (let i = 0; i < res.data.list.length; i++) {
- if (res.data.list[i].province == authenticationStatus.city){
- this.setData({
- provinceValue: i,
- storeArr: this.data.provinceArr[i].children,
- storeValue: 0
- })
- break;
- }
- }
- }
- } else {
- wx.showToast({
- title: res.msg,
- icon: "none"
- })
- }
- }, this);
- },
- provinceChane: function (e) {//选中省
- this.setData({
- provinceValue: e.detail.value,
- storeArr: this.data.provinceArr[e.detail.value].children,
- storeValue: 0
- })
- },
- storeChane: function (e) {//选中店铺
- this.setData({
- storeValue: e.detail.value,
- })
- },
- getRealname: function (e) {//获取用户输入的姓名
- this.data.realname = e.detail.value;
- },
- submitMsg: function () {
- if(!this.data.realname){
- wx.showToast({
- title: '请输入姓名',
- icon:'none'
- })
- return;
- }
- if (!this.data.isAgreement) {
- wx.showToast({
- title: '请同意协议',
- icon: 'none'
- })
- return;
- }
- var data = {
- realName:this.data.realname,
- jobId: this.data.jobList[this.data.jobValue].jobId,
- jobDetail: this.data.jobList[this.data.jobValue].jobDetail,
- agentDetail: this.data.storeArr[this.data.storeValue]['agent_detail'],
- agentCode: this.data.storeArr[this.data.storeValue]['agent_code'],
- city: this.data.provinceArr[this.data.provinceValue]['province']
- }
- app.wxRequest(app.globalData.urlRoot + "certificationInfo/submitCertificationInfoData", data,res=>{
- if (res.code == 200) {
- app.globalData.authenticationStatus.realName = this.data.realname
- app.globalData.authenticationStatus.jobId = this.data.jobList[this.data.jobValue].jobId
- app.globalData.authenticationStatus.jobDetail = this.data.storeArr[this.data.storeValue]['agent_detail']
- app.globalData.authenticationStatus.city = this.data.provinceArr[this.data.provinceValue]['province']
- app.globalData.authenticationStatus.agentDetail = this.data.storeArr[this.data.storeValue]['agent_detail']
-
- wx.navigateBack({
- delta: 1,
- })
- }else{
- wx.showToast({
- title: res.msg,
- icon:'none'
- })
- }
- },this,"POST");
- }
- })
|