123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- App({
- data: {
- userId: '',
- userBalance: '',
- refreshFlag:false,
- // host: '192.168.0.200:8180',
- // baseUrl: 'http://192.168.0.200:8180',
- host: '121.236.175.200:8180',
- baseUrl: 'http://121.236.175.200:8180',
- },
- onLaunch(options) {
- //获取用户信息
- var that = this
- var app = getApp()
- dd.getAuthCode({
- success: function (res) {
- app.requestHps('/system/dingLogin/login', { code: res.authCode }).then(res => {
- if (res.data.code == 0) {
- that.data.userId = res.data.data
- } else {
- dd.alert({
- content: res.msg,
- buttonText: '我知道了',
- });
- }
- })
- },
- fail: function (err) {
- console.log(err)
- dd.alert({
- content: err.message,
- buttonText: '我知道了',
- });
- }
- })
- },
- requestHp(url, data = {}) {
- var that = this
- return new Promise((resolve, reject) => {
- dd.showLoading({
- content: '加载中...',
- });
- dd.httpRequest({
- url: that.data.baseUrl + url,
- method: 'POST',
- data: data,
- dataType: 'json',
- headers: {
- "Content-Type": "application/json"
- },
- success: function (res) {
- // 请求成功
- dd.hideLoading()
- resolve(res)
- var msg = res.data.msg
- if (res.data.code == 0 || res.data.code == 200) {
- resolve(res)
- } else {
- dd.alert({
- content: msg,
- buttonText: '我知道了',
- });
- }
- },
- fail: function (res) {
- console.log(res)
- // 请求失败
- dd.alert({
- content: res.message,
- buttonText: '我知道了',
- });
- dd.hideLoading()
- reject(res)
- },
- complete: function (res) {
- // 请求调用结束 都会执行
- }
- });
- })
- },
- requestHps(url, data = {}) {
- var that = this
- return new Promise((resolve, reject) => {
- dd.showLoading({
- content: '加载中...',
- });
- dd.httpRequest({
- url: that.data.baseUrl + url,
- method: 'GET',
- data: data,
- dataType: 'json',
- headers: {
- "Content-Type": "application/json"
- },
- success: function (res) {
- dd.hideLoading()
- // 请求成功
- resolve(res)
- var msge = res.data.msg
- if (res.data.code == 0 || res.data.code == 200) {
- resolve(res)
- } else {
- dd.alert({
- content: msge,
- buttonText: '我知道了',
- });
- }
- },
- fail: function (res) {
- console.log(res)
- dd.hideLoading()
- // 请求失败
- dd.alert({
- content: res.message,
- buttonText: '我知道了',
- });
- reject(res)
- },
- complete: function (res) {
- // 请求调用结束 都会执行
- }
- });
- })
- },
- });
|