| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 |
- // index.js
- // 获取应用实例
- const app = getApp()
- import http from "../../utils/http"
- import util from "../../utils/util"
- Page({
- data: {
- checked: false,
- show:false,
- menuH: '32px',
- safeTop: `40px`,
- lastAddress: '',
- list:[],
- finish: false,
- loading: false,
- page: 1,
- orderCount: [],
- token: wx.getStorageSync('token'),
- code: '',
- config: ''
- },
- // 服务时间
- toServerTime(){
- util.authSkip('/service/serverTime/serverTime')
- },
- detail(e){
- util.skip('/pages/orderDetail/orderDetail?id='+e.currentTarget.dataset.id)
- },
- // 事件处理函数
- onChange({ detail }) {
- if(!wx.getStorageSync('token')) {
- util.skip('/service/login/login')
- return
- }
- http.post('skill/updateskillinfo',{type: 'update', is_rest: Number(!detail)}).then(res => {
- this.setData({
- checked: detail
- })
- })
- },
- onClose(){
- this.setData({
- show: false
- })
- },
- notice(){
- wx.requestSubscribeMessage({
- tmplIds: [app.globalData.templateconfig.skill_order_template,app.globalData.templateconfig.skill_sales_template],
- success :(res) =>{
- console.log(res)
- },
- fail :(e) =>{
- console.log(e)
- },
- complete :(res) =>{
- this.changeAddress()
- }
- })
- },
- changeAddress(){
- if(!wx.getStorageSync('token')) {
- util.skip('/service/login/login')
- return
- }
- http.post('skill/updateskillinfo',{
- type: 'update',
- province: this.data.address.province,
- city: this.data.address.city,
- district: this.data.address.district,
- address: this.data.address.name,
- lng: this.data.address.lng,
- lat: this.data.address.lat,
- }).then(res => {
- this.setData({
- show: true,
- lastAddress: this.data.address.city + ' ' +this.data.address.name
- })
- })
- },
- getInfo(){
- if(!wx.getStorageSync('token')) return
- http.post('skill/updateskillinfo','',!this.data.code).then(res => {
- if(res.data){
- this.setData({
- checked: res.data.is_rest === 0,
- lastAddress: res.data.city+ ' ' + res.data.address,
- code: res.data.code
- })
- }
- })
- http.post('skill/skillhome','',!this.data.orderCount).then(res => {
- this.setData({
- orderCount: res.data.orderCount
- })
- })
- },
- order(){
- wx.switchTab({
- url: '/pages/order/order'
- })
- },
- reload(){
- this.setData({
- list: [],
- page: 1,
- finish: false
- })
- this.getList()
- },
- more(){
- this.setData({
- page: ++this.data.page
- })
- this.getList()
- },
- getList(){
- if(!wx.getStorageSync('token')) return
- if(this.data.finish){
- return
- }
- if(this.data.loading){
- return
- }
- this.setData({
- loading: true
- })
- let data = {
- page: this.data.page,
- not_finish: 1
- }
- http.post('order/skillorderlist', data).then(res => {
- if(res.data.length === 0){
- this.setData({
- finish: true
- })
- }
- let arr = this.data.list.concat(res.data)
- this.setData({
- list: arr
- })
-
- }).finally(res => {
- this.setData({
- loading: false
- })
- })
- },
- knowLocation(){
- wx.navigateTo({
- url: '/service/login/login'
- })
- },
- toTraining() {
- wx.navigateTo({
- url: '/pages/training/training'
- })
- },
- testbtn(){
- this.setData({
- loading:true
- })
- setTimeout(()=>
- {
- this.setData({
- loading:false
- })
- }, 2000)
- console.log(this.data.loading)
- },
- onLoadAddress(option){
- this.setData({
- address: app.globalData.address
- })
- },
- onLoadConfig(option){
- this.setData({
- config: app.globalData.config
- })
- },
- onLoad() {
- this.setData({
- safeTop: `${app.globalData.safeTop}px`,
- menuH: `${app.globalData.menuH}px`,
- })
-
-
- },
- onShow(){
- this.setData({
- token: wx.getStorageSync('token')
- })
- this.getInfo()
- this.reload()
- },
-
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- return {}
- }
- })
|