import Vue from 'vue'
import App from './App'

Vue.config.productionTip = false

// Vue.prototype.apiUrl = "http://tudoujiaju.t.brotop.cn/api"
Vue.prototype.apiUrl = "https://t-d-h.com/api"

App.mpType = 'app'

Vue.prototype.$loginRequest = function(url, data = '', method) {
	// var that=this
	return new Promise((reslove, reject) => {
		uni.request({
			url: this.apiUrl + url,
			method: method,
			header: {
				'token': uni.getStorageSync('token')
			},
			data: data,
			success: (res) => {
				console.log(res)
				//token错误和返回结果都是用code
				if (res.data.code == 0) {
					// reslove({
					// 	"tcode": 0,
					// 	"msg": "未登录"
					// })
					// this.code=0
					reslove(res.data)
				}
				if (res.data.code == 1) {
					reslove(res.data)
				}
				 
				//  else if (res.data.code == '401') {
				// 	uni.showToast({
				// 		title: '请登录后操作',
				// 		icon: 'none'
				// 	})
				// } else if (uni.getStorageSync('token') == '') {
				// 	uni.reLaunch({
				// 		url: '/pages/index/indexNoLogin.vue'
				// 	})

				// }


				if (res.data.code == 0 || res.data.code) {
					reslove(res.data)
				}
			}
		})
	})
}












const app = new Vue({
    ...App
})
app.$mount()