Commit efe40d98 by 张立顺

配置修改

2 parents 8f775219 0e2bb35f
......@@ -27,13 +27,13 @@ class UsersApi {
/**授权手机号 */
async authUserPhone(detail, sessionId) {
if (!sessionId) {
wx.$util.showToast('缺少sessionId')
wx.$api.showToast('缺少sessionId')
Promise.reject()
}
if (detail.errMsg && detail.errMsg == 'getPhoneNumber:fail user deny') Promise.reject()
delete detail.errMsg
if (detail.iv && detail.encryptedData) {
wx.$util.showLoading()
wx.$api.showLoading()
detail.sessionId = sessionId
return api.post(
{
......
// app.js
import util from './utils/util.js'
import '~/router/routerBefore.js'
import router from './router/index.js'
import util from './utils/util'
import wxApi from './utils/utils_wx'
import '~/router/routerBefore'
import router from './router/index'
// 有问题 前后顺序不能随意调整
......@@ -29,6 +30,7 @@ App({
/**挂载到wx对象 */
wx.$authStatus = false
wx.$util = util
wx.$api = wxApi
wx.$router = router
wx.$storage = $Storage /** 挂载全局缓存方法 */
wx.$eventbus = eventbus
......@@ -45,6 +47,5 @@ App({
wx.$router.goHome()
},
onHide() {},
globalData: {
}
globalData: {}
})
// pages/login/index/index.js
Page({
/**
* 页面的初始数据
*/
......@@ -12,24 +11,20 @@ Page({
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
onLoad(options) {},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
onReady() {},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
wx.$util.showLoading()
wx.$api.showLoading()
wx.hideHomeButton({
success: (res) => {
success: res => {
wx.hideLoading()
}
})
......@@ -38,35 +33,25 @@ Page({
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
onHide() {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
onUnload() {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
onPullDownRefresh() {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
onReachBottom() {},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file
onShareAppMessage() {}
})
// pages/webView/webView.js
Page({
/**
* 页面的初始数据
*/
......@@ -24,16 +23,16 @@ Page({
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
wx.$util.showLoading('加载中...')
let decodeUrl = decodeURIComponent(options.url);
onLoad: function (options) {
wx.$api.showLoading('加载中...')
let decodeUrl = decodeURIComponent(options.url)
let param = this.getParams(decodeUrl)
if (param.urlParam) {
let query = JSON.parse(param.urlParam)
this.data.refresh = query.refresh
}
this.setData({
url: decodeUrl,
url: decodeUrl
})
wx.hideLoading()
},
......@@ -41,29 +40,30 @@ Page({
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
},
onReady: function () {},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
onShow: function () {
if (this.data.refresh) {
this.setData({
flag: true
}, () => {
this.setData({
url: this.data.url
})
})
this.setData(
{
flag: true
},
() => {
this.setData({
url: this.data.url
})
}
)
}
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
onHide: function () {
if (this.data.refresh) {
this.setData({
flag: false
......@@ -74,7 +74,7 @@ Page({
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
onUnload: function () {
if (this.data.refresh) {
this.setData({
flag: false
......@@ -85,14 +85,10 @@ Page({
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
onPullDownRefresh: function () {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
}
})
\ No newline at end of file
onReachBottom: function () {}
})
{
"setting": {
"compileHotReLoad": false,
"compileHotReLoad": true,
"urlCheck": false,
"lazyloadPlaceholderEnable": true
},
<<<<<<< HEAD
"condition": {
"miniprogram": {
"list": [
......@@ -18,6 +19,10 @@
}
},
"projectname": "miniprogram-template",
=======
"condition": {},
"projectname": "business-assistant",
>>>>>>> zhangls_v3.0
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"libVersion": "2.24.4"
}
\ No newline at end of file
......@@ -30,59 +30,6 @@ Date.prototype.format = function (fmt) {
return fmt
}
/**
* 防止重复点击
*/
const showLoading = (title = '') => {
if (wx.showLoading) {
// 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理
wx.showLoading({
title,
mask: true
})
} else {
// 低版本采用Toast兼容处理并将时间设为20秒以免自动消失
wx.showToast({
title,
icon: 'loading',
mask: true,
duration: 20000
})
}
}
const hideLoading = () => {
if (wx.hideLoading) {
// 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理
wx.hideLoading()
} else {
wx.hideToast()
}
}
const showToast = val => {
let obj = {}
if (val && typeof val === 'string') {
obj.title = val
obj.icon = 'none'
} else {
obj = val
}
return wx.showToast(obj)
}
/**获取节点信息
* name(id获取class)
* callBack 回调函数
* isComponents是否在组件
*/
const getViewInfo = (name, callBack, isComponents) => {
const query = !isComponents ? wx.createSelectorQuery() : wx.createSelectorQuery().in(isComponents)
query
.select(name)
.boundingClientRect(res => {
callBack(res)
})
.exec()
}
/**触底加载 */
const onReachBottom = (obj, callBack) => {
let _this = $router.getPageInstance()
......@@ -105,21 +52,6 @@ const onReachBottom = (obj, callBack) => {
}
}
/**
* 禁止滑动
*/
const noScroll = () => {}
/**设置粘贴板内容 */
const setCopyData = (data, callBack) => {
wx.setClipboardData({
data: data,
success(res) {
if (callBack && typeof callBack === 'function') callBack(res)
}
})
}
/**是否全面屏 */
const isFullSucreen = isComponents => {
const thisPage = $router.getPageInstance()
......@@ -150,30 +82,6 @@ const isFullSucreen = isComponents => {
return val
}
/**获取手机信息 */
const getPhoneInfo = callBack => {
wx.getSystemInfo({
success(res) {
callBack(res)
},
fail(err) {
callBack(err)
}
})
}
/**拨打电话 */
const phoneCall = phoneNumber => {
wx.makePhoneCall({
phoneNumber: `${phoneNumber}`
})
}
/**查看大图 */
const previewImage = params => {
wx.previewImage(params)
}
/**节流 */
const throttle = (fn, gapTime) => {
if (gapTime == null || gapTime == undefined) {
......@@ -212,21 +120,10 @@ const getImgVersion = () => {
}
const Util = {
// setNavigationBarTitleText,
// getNavigationBarTitleText,
getImgVersion,
onReachBottom,
isFullSucreen,
previewImage,
getPhoneInfo,
clearObjNull,
showLoading,
hideLoading,
getViewInfo,
setCopyData,
showToast,
phoneCall,
noScroll,
throttle
}
export default Util
/**
* 微信校验通知类工具封装
*/
const tipsObj = {
phone: {
icon: 'error',
title: '请输入手机号'
},
username: {
icon: 'error',
title: '请输入用户名'
},
password: {
icon: 'error',
title: '请输入密码'
}
}
/**
* 禁止滑动
*/
const noScroll = () => {}
/**设置粘贴板内容 */
const setCopyData = (data, callBack) => {
wx.setClipboardData({
data: data,
success(res) {
if (callBack && typeof callBack === 'function') callBack(res)
}
})
}
/**
* 防止重复点击
*/
const showLoading = (title = '') => {
if (wx.showLoading) {
// 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理
wx.showLoading({
title,
mask: true
})
} else {
// 低版本采用Toast兼容处理并将时间设为20秒以免自动消失
wx.showToast({
title,
icon: 'loading',
mask: true,
duration: 20000
})
}
}
const hideLoading = () => {
if (wx.hideLoading) {
// 基础库 1.1.0 微信6.5.6版本开始支持,低版本需做兼容处理
wx.hideLoading()
} else {
wx.hideToast()
}
}
const showToast = val => {
let obj = {}
if (val && typeof val === 'string') {
obj.title = val
obj.icon = 'none'
} else {
obj = val
}
return wx.showToast(obj)
}
/**
*
* @param {* string | object} name 信息名称
* @param {* object | null} [params] 信息名称参数
*/
const wxShowToast = (name, params) => {
if (arguments.length == 2) {
wx.showToast({
title: tipsObj[name]['title'],
icon: tipsObj[name]['icon'],
...params
})
} else {
wx.showToast({
...params
})
}
}
/**获取设备信息 */
const getSystemInfo = callBack => {
wx.getSystemInfo({
success(res) {
callBack(res)
},
fail(err) {
callBack(err)
}
})
}
/**拨打电话 */
const phoneCall = phoneNumber => {
wx.makePhoneCall({
phoneNumber: `${phoneNumber}`
})
}
/**查看大图 */
const previewImage = params => {
wx.previewImage(params)
}
const wxApi = {
previewImage,
getSystemInfo,
showLoading,
hideLoading,
setCopyData,
showToast,
phoneCall,
noScroll
}
export default wxApi
/**
* 微信校验通知类工具封装
*/
const tipsObj = {
phone: {
icon: "error",
title: "请输入手机号",
},
username: {
icon: "error",
title: "请输入用户名",
},
password: {
icon: "error",
title: "请输入密码",
},
};
/**
*
* @param {* string | object} name 信息名称
* @param {* object | null} [params] 信息名称参数
*/
const wxShowToast = (name, params) => {
if (arguments.length == 2) {
wx.showToast({
title: tipsObj[name]["title"],
icon: tipsObj[name]["icon"],
...params,
});
} else {
wx.showToast({
...params,
});
}
};
export default wxShowToast;
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!