123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- // pages/tabber/home/index.js
- const app = getApp();
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- menuList: [
- {
- url: '/image/home/ruhexiadan.png',
- text: '如何下单'
- },
- {
- url: '/image/home/changjianwenti.png',
- text: '常见问题'
- }
- ,
- {
- url: '/image/home/xidifanwei.png',
- text: '洗涤范围'
- }
- ],
- current: 3,
- btnInfo: app.globalData.btnInfo,
- topShow: true,
- worke: [],
- status: "",
- islocation: ""
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- },
- onShow: function (options) {
- this.setData({
- islocation: wx.getStorageSync('islocation'),
- status: app.globalData.status,
-
- })
- var nid =wx.getStorageSync('nid');
- var token =wx.getStorageSync('token');
- if(!nid || !token){
- app.login().then(res => {
- console.log(res)
- this.setData({
- token: res.message.token,
- nid: res.message.network_id
- })
- this.workDesc(res.message.network_id);
- })
-
- }else{
- this.workDesc(nid);
- }
-
- },
- onReady: function () {
-
- },
- //网点详情
- workDesc: function (nid="") {
- var that = this;
-
- if (!nid) {
- that.setData({
- worke: { 'title': '请选择网点', 'institution_id': 0, 'business_status': 3, 'distance': 0 }
- })
- return false;
- }
- app.api.useApi(app.globalData.baseAppUrl + "api/network/desc", {
- network_id: nid,
- }, "get").then(function (res) {
- if (res.code != 200) {
- wx.showLoading({
- title: '网点加载失败' + res.status,
- })
- } else {
- that.setData({
- worke: res.message.data
- })
- }
- wx.hideLoading();
- }).catch(function (err) {
- console.log(222);
- })
- },
- toMap() {
- wx.navigateTo({
- url: '/pages/home/map/map',
- })
- },
- placeOrder() {
- if (this.data.islocation) {
- this.getLocation()
- }
- var parmise=this.data.worke;
- wx.navigateTo({
- url: '/pages/order/placeOrder/placeOrder?parmise='+JSON.stringify(parmise),
- })
- },
- close() {
- this.setData({
- topShow: false
- })
- },
- onReady: function () {
- this.toast = this.selectComponent("#toast");
- },
- listenerLogin: function () {
- this.toast.showToast('领取成功');
- },
- rightClick(e) {
- console.log(1);
- },
- getLocation(e) {
- var that = this;
- wx.getLocation({
- success(res) {
- console.log('开启后台定位', res)
-
- console.log('location change', res)
- that.setData({
- location: res,
- islocation: true,
- })
- app.api.useApi(app.globalData.baseAppUrl + "api").then(function (res) {
- console.log(res)
- }, function (error) {
- console.log(error);
- })
-
- },
- fail(res) {
- console.log('开启后台定位失败', res);
- that.setData({
- islocation: true
- })
- wx.showLoading({
- title: '开启后台定位失败,请重试。',
- })
- return false;
- }
- })
- }
- })
|