123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679 |
- // pages/index/index.js
- import {
- xcxsfsm,
- hqdw,
- xcxGetCompanyList,
- xcxGetCompanySwjg,
- xcxsmbd,
- xcxsy,
- } from "../../apis/index.js";
- // 屏幕信息
- let screenInfo = null;
- let movableInfo = null;
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- navigation: {},
- addressInfo: {},
- userInfo: {},
- enterPriceList: [],
- enterpriceTypeShow: false,
- hall: {},
- markers: [],
- myYy: {},
- showVoice: false,
- searchValue: "",
- lbList: [
- {
- url:
- "https://smzc-1253299035.cos.ap-nanjing.myqcloud.com/pdjh/miniProgrameYyQh/indexLb1.png",
- name: "税费争议",
- event: "navigate",
- path: "../taxDisputes/index/index",
- },
- {
- url:
- "https://smzc-1253299035.cos.ap-nanjing.myqcloud.com/pdjh/miniProgrameYyQh/indexLb2.png",
- name: "",
- event: "miniProgram",
- appId: "wxc575845fbd5bac33",
- },
- ],
- lbIndex: 0,
- znzxX: 0,
- znzxY: "500rpx",
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- let that = this;
- that.init();
- that.getNavigationBar();
- that.getIndexInfos();
- },
- init() {
- let that = this;
- let device = wx.getSystemInfoSync();
- screenInfo = device.screenWidth - 50;
- that.setData({
- znzxX: screenInfo,
- });
- },
- getNavigationBar() {
- let that = this;
- const res = wx.getMenuButtonBoundingClientRect();
- let navigation = {
- width: res.left + "px",
- height: res.height + 6 + "px",
- paddingTop: res.top - 3 + "px",
- };
- that.setData({
- navigation: navigation,
- });
- },
- getIndexInfos() {
- let that = this;
- that.sfsm();
- },
- hqdw() {
- let that = this;
- wx.getLocation({
- type: "wgs84",
- isHighAccuracy: true,
- success(result) {
- hqdw().then((res) => {
- if (res.code == 200) {
- let data = JSON.parse(res.message);
- that.setData({
- addressInfo: {
- lat: result.latitude,
- lng: result.longitude,
- address:
- data.result.ad_info.district ||
- data.result.ad_info.city ||
- data.result.ad_info.province ||
- data.result.ad_info.nation,
- },
- });
- wx.setStorageSync(
- "ADDRESS",
- data.result.ad_info.district ||
- data.result.ad_info.city ||
- data.result.ad_info.province ||
- data.result.ad_info.nation
- );
- } else {
- that.setData({
- addressInfo: {
- lat: result.latitude,
- lng: result.longitude,
- address: "未知",
- },
- });
- wx.setStorageSync("ADDRESS", "未知");
- }
- });
- },
- fail: (err) => {
- hqdw().then((res) => {
- if (res.code == 200) {
- let data = JSON.parse(res.message);
- that.setData({
- addressInfo: {
- lat: data.result.location.lat,
- lng: data.result.location.lng,
- address:
- data.result.ad_info.district ||
- data.result.ad_info.city ||
- data.result.ad_info.province ||
- data.result.ad_info.nation,
- },
- });
- wx.setStorageSync(
- "ADDRESS",
- data.result.ad_info.district ||
- data.result.ad_info.city ||
- data.result.ad_info.province ||
- data.result.ad_info.nation
- );
- } else {
- that.setData({
- addressInfo: {
- lat: "",
- lng: "",
- address: "未知",
- },
- });
- wx.setStorageSync("ADDRESS", "未知");
- }
- });
- },
- });
- },
- authorizeSuccess() {
- let that = this;
- that.getIndexInfos();
- },
- sfsm() {
- let that = this;
- let publicId = wx.getStorageSync("PUBLIC_ID");
- if (publicId.unionid) {
- xcxsfsm({
- xcxId: publicId.openid,
- unionid: publicId.unionid,
- }).then((res) => {
- switch (res.code) {
- default:
- return;
- case 200:
- wx.setStorageSync("REAL_NAME", true);
- wx.setStorageSync("LOCK", false);
- var userInfos = {
- name: res.smxx.xm,
- idcard: res.smxx.sfzhm,
- phone: res.smxx.sjh,
- swjgdm: res.smxx.swjgdm || "",
- nsrsbh: res.smxx.nsrsbh || "",
- nsrmc: res.smxx.nsrmc || "",
- };
- wx.setStorageSync("USERINFO", userInfos);
- that.setData({
- userInfo: userInfos,
- });
- break;
- case 501:
- wx.setStorageSync("REAL_NAME", false);
- wx.setStorageSync("LOCK", false);
- wx.removeStorageSync("USERINFO");
- wx.removeStorageSync("MY_HALL");
- break;
- case 502:
- wx.setStorageSync("REAL_NAME", true);
- wx.setStorageSync("LOCK", true);
- var userInfos = {
- name: res.smxx.xm,
- idcard: res.smxx.sfzhm,
- phone: res.smxx.sjh,
- swjgdm: res.smxx.swjgdm || "",
- nsrsbh: res.smxx.nsrsbh || "",
- nsrmc: res.smxx.nsrmc || "",
- };
- wx.setStorageSync("USERINFO", userInfos);
- that.setData({
- userInfo: userInfos,
- });
- break;
- case 500:
- wx.removeStorageSync("USERINFO");
- wx.removeStorageSync("MY_HALL");
- break;
- }
- });
- } else {
- setTimeout(() => {
- that.sfsm();
- }, 500);
- }
- },
- getHall() {
- let that = this;
- let publicId = wx.getStorageSync("PUBLIC_ID");
- if (that.data.addressInfo.lat && that.data.addressInfo.lng) {
- let form = {
- xcxId: publicId.openid,
- unionid: publicId.unionid,
- longitude: String(that.data.addressInfo.lng),
- latitude: String(that.data.addressInfo.lat),
- nsrsbh: that.data.userInfo.nsrsbh || "",
- swjgdm: that.data.userInfo.swjgdm || "",
- };
- xcxsy(form).then((res) => {
- if (res.code == 200) {
- let halls = res.list.sort((a, b) => {
- return a.zxjl - b.zxjl;
- });
- wx.setStorageSync("HALL_LIST", halls);
- that.setMyHall(halls);
- that.setData({
- myYy: res.yyjl,
- });
- } else {
- wx.showToast({
- title: res.msg || res.message,
- icon: "none",
- duration: 5000,
- });
- }
- });
- } else {
- setTimeout(() => {
- that.getHall();
- }, 500);
- }
- },
- setMyHall(e) {
- let that = this;
- let userinfo = wx.getStorageSync("USERINFO");
- let myhall = wx.getStorageSync("MY_HALL");
- if (myhall) {
- let update = false;
- for (let i = 0; i < e.length; i++) {
- if (e[i].bsfwtDm == myhall.bsfwtDm) {
- update = true;
- that.setData({
- hall: e[i],
- });
- that.setMarker(e[i]);
- wx.setStorageSync("MY_HALL", e[i]);
- break;
- }
- }
- if (!update) {
- that.setData({
- hall: myhall,
- });
- that.setMarker(myhall);
- }
- } else {
- if (userinfo.swjgdm) {
- let hall = {};
- let uswjgdm = userinfo.swjgdm.substring(0, 7);
- for (let i = 0; i < e.length; i++) {
- let hswjgdm = e[i].ssswjgDm.substring(0, 7);
- if (uswjgdm == hswjgdm) {
- hall = e[i];
- break;
- }
- }
- if (!hall.bsfwtmc) hall = e[0];
- that.setData({
- hall: hall,
- });
- wx.setStorageSync("MY_HALL", hall);
- that.setMarker(hall);
- } else {
- let hall = e[0];
- that.setData({
- hall: hall,
- });
- wx.setStorageSync("MY_HALL", hall);
- that.setMarker(hall);
- }
- }
- },
- setMarker(e) {
- let that = this;
- let lat = e.latitude || e.lat;
- let lng = e.longitude || e.lng;
- let marker = {
- id: 9527,
- latitude: lat,
- longitude: lng,
- title: "",
- zIndex: 9,
- alpha: 0.9,
- iconPath: "../../icon/address.png",
- width: "30rpx",
- height: "30rpx",
- callout: {
- content: "大厅地址",
- color: "#313131",
- textAlign: "center",
- fontSize: 10,
- borderRadius: 5,
- bgColor: "#ffffff",
- padding: 5,
- display: "ALWAYS",
- },
- };
- that.setData({
- markers: [marker],
- });
- },
- changeType() {
- let that = this;
- let authorize = getApp().globalData.authorize();
- if (authorize == 0) {
- let nsrmc = that.data.userInfo.nsrmc;
- if (nsrmc.length > 2) {
- wx.showLoading({
- title: "正在切换身份...",
- });
- let publicId = wx.getStorageSync("PUBLIC_ID");
- let form = {
- xcxId: publicId.openid,
- unionid: publicId.unionid,
- xm: that.data.userInfo.name,
- sfzjhm: that.data.userInfo.idcard,
- sjh: that.data.userInfo.phone,
- nsrmc: "",
- nsrsbh: "",
- swjgdm: "",
- };
- xcxsmbd(form).then((res) => {
- wx.hideLoading();
- if (res.code == 200) {
- that.getIndexInfos();
- that.close();
- } else {
- wx.showToast({
- title: res.msg || res.message,
- icon: "none",
- duration: 5000,
- });
- }
- });
- } else {
- that.changeEnterprice();
- }
- } else {
- let authorizeBox = this.selectComponent("#authorizeBox");
- authorizeBox.show();
- }
- },
- changeEnterprice() {
- let that = this;
- that.setData({
- enterPriceList: [],
- });
- let authorize = getApp().globalData.authorize();
- if (authorize == 0) {
- wx.showLoading({
- title: "正在获取企业信息",
- });
- that.setData({
- enterpriceTypeShow: true,
- });
- xcxGetCompanyList({
- xm: that.data.userInfo.name,
- sfzjhm: that.data.userInfo.idcard,
- }).then((res) => {
- wx.hideLoading();
- if (res.code == 200) {
- that.setData({
- enterPriceList: res.list,
- });
- } else {
- wx.showToast({
- title: res.msg || res.message,
- icon: "none",
- duration: 5000,
- });
- }
- });
- }
- },
- async selectEnterprice(e) {
- let that = this;
- wx.showLoading({
- title: "正在切换...",
- });
- let publicId = wx.getStorageSync("PUBLIC_ID");
- let item = e.currentTarget.dataset.item;
- let form = {
- xcxId: publicId.openid,
- unionid: publicId.unionid,
- xm: that.data.userInfo.name,
- sfzjhm: that.data.userInfo.idcard,
- sjh: that.data.userInfo.phone,
- nsrmc: item.nsrmc,
- nsrsbh: item.nsrsbh,
- swjgdm: (await that.getEnterpriceSwjgdm(item)) || "",
- };
- xcxsmbd(form).then((res) => {
- wx.hideLoading();
- if (res.code == 200) {
- that.close();
- let userinfo = {
- idcard: form.sfzjhm,
- name: form.xm,
- nsrmc: form.nsrmc,
- nsrsbh: form.nsrsbh,
- phone: form.sjh,
- swjgdm: form.swjgdm,
- };
- wx.setStorageSync("USERINFO", userinfo);
- that.setData({
- userInfo: userinfo,
- });
- wx.removeStorageSync("MY_HALL");
- that.setMyHall(wx.getStorageSync("HALL_LIST"));
- } else {
- wx.showToast({
- title: res.msg || res.message,
- icon: "none",
- duration: 5000,
- });
- }
- });
- },
- getEnterpriceSwjgdm(e) {
- return new Promise((resolve, rejects) => {
- let form = {
- djxh: e.djxh,
- nsrsbh: e.nsrsbh,
- };
- xcxGetCompanySwjg(form).then((res) => {
- if (res.code == 200) {
- resolve(res.swjgdm);
- } else {
- resolve(null);
- }
- });
- });
- },
- close() {
- let that = this;
- that.setData({
- enterpriceTypeShow: false,
- });
- },
- selectHall(e) {
- let that = this;
- let type = e.currentTarget.dataset.type;
- let authorize = getApp().globalData.authorize();
- if (authorize == 0) {
- wx.navigateTo({
- url: "../indexPages/selectHall/selectHall?type=" + type,
- });
- } else {
- let authorizeBox = this.selectComponent("#authorizeBox");
- authorizeBox.show();
- }
- },
- start(e) {
- let type = e.currentTarget.dataset.type;
- let authorize = getApp().globalData.authorize();
- if (authorize == 0) {
- wx.navigateTo({
- url: "../indexPages/selectBusiness/selectBusiness?type=" + type,
- });
- } else {
- let authorizeBox = this.selectComponent("#authorizeBox");
- authorizeBox.show();
- }
- },
- toYyDetail(e) {
- let item = e.currentTarget.dataset.item;
- wx.navigateTo({
- url: "../recordPages/yyjl/yyjl?infos=" + JSON.stringify(item),
- });
- },
- toLookSsqh() {
- wx.switchTab({
- url: "../record/record",
- });
- },
- startSmrz() {
- let authorizeBox = this.selectComponent("#authorizeBox");
- authorizeBox.show();
- },
- toSearch() {
- console.log("search");
- },
- indexSearchInput(e) {
- let that = this;
- let value = e.detail.value;
- that.setData({
- searchValue: value,
- });
- },
- startVoice() {
- let that = this;
- that.setData({
- showVoice: true,
- });
- },
- closeVoice() {
- let that = this;
- that.setData({
- showVoice: false,
- });
- },
- resVoice(e) {
- let that = this;
- let searchValue = that.data.searchValue;
- searchValue = searchValue + e.detail;
- that.setData({
- searchValue: searchValue,
- });
- that.closeVoice();
- },
- movableEnd() {
- let that = this;
- if (movableInfo) {
- that.setData({
- znzxX: movableInfo.x,
- znzxY: movableInfo.y,
- });
- movableInfo = null;
- }
- },
- movable(e) {
- let that = this;
- let now = e.detail;
- let x = 0;
- if (now.x > screenInfo / 2) {
- x = screenInfo;
- } else {
- x = 0;
- }
- movableInfo = {
- x: x,
- y: now.y,
- };
- },
- toZnzx() {
- wx.navigateTo({
- url: "../other/znzx/znzx",
- });
- },
- lbChage(e) {
- let that = this;
- that.setData({
- lbIndex: e.detail.current,
- });
- },
- swiperTap(e) {
- let item = e.currentTarget.dataset.item;
- switch (item.event) {
- case "navigate":
- wx.navigateTo({
- url: item.path,
- });
- break;
- case "miniProgram":
- wx.navigateToMiniProgram({
- appId: item.appId,
- fail(err) {
- wx.showToast({
- title: '跳转工行服务小程序失败',
- icon: "none"
- })
- }
- })
- break;
- default:
- break;
- }
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {},
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- let that = this;
- that.hqdw();
- that.getHall();
- that.getIndexInfos();
- let userInfo = wx.getStorageSync("USERINFO");
- that.setData({
- userInfo: userInfo,
- });
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {},
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {},
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {},
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {},
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {},
- });
|