Commit 6352bf20 by 张立顺

合并代码

1 parent b45c23a0
// components/image/index.js
import {
IMG_URL,
IMG_VERSION
} from '~/utils/constantData'
import { IMG_URL, IMG_VERSION } from '~/utils/constantData'
Component({
externalClasses: ['custom-class', 'class'],
/**
......@@ -37,15 +34,11 @@ Component({
})
},
// 在组件实例被从页面节点树移除时执行
detached: function () {
}
detached: function () {}
},
/**
* 组件的方法列表
*/
methods: {
}
})
\ No newline at end of file
methods: {}
})
......@@ -2,8 +2,6 @@
import mineApi from '~/api/mineApi/index'
// import USERAPI from '~/api/usersApi/index'
import { IMG_URL } from '~/utils/constantData'
// console.log(IMG_URL)
// import { behavior as computedBehavior } from '~/utils/lib/miniprogram-computed'
const listObj = Object.freeze([
{
......@@ -62,7 +60,6 @@ const listObj = Object.freeze([
}
])
Component({
// behaviors: [computedBehavior],
options: {
addGlobalClass: true
},
......@@ -95,33 +92,11 @@ Component({
isSuper: userInfo.isSuper
})
this.getMerchantCustomInfoList()
this.testFn()
},
// computed: {
// test(data) {
// return data.bgUrl + data.pageNum
// }
// },
// watch: {
// 'test, pages': function (a, b) {
// console.log(a)
// // this.setData({
// // sum: a + b,
// // })
// }
// },
/**
* 组件的方法列表
*/
methods: {
// testFn() {
// // let {}
// let name = `testData[0].a`
// this.setData({
// [name]: 2
// })
// },
restPageNum() {
console.log('restPageNum')
this.setData({
......@@ -130,7 +105,7 @@ Component({
this.getMerchantCustomInfoList()
},
scrollonReachBottom() {
console.log('scrollonReachBottom')
// console.log('scrollonReachBottom')
let { pages, pageNum } = this.data
// 判断当前页是否是末页
if (pages == pageNum) return wx.$api.showToast('列表已到底')
......
......@@ -18,10 +18,11 @@ class Router {
console.log(thisPage)
if (thisPage) {
thisPage.setData({ IMG_URL, img_version: IMG_VERSION() })
if (Object.keys(this[_query]).length) thisPage.options = {
...thisPage.options,
...this[_query]
}
if (Object.keys(this[_query]).length)
thisPage.options = {
...thisPage.options,
...this[_query]
}
this.setNavigationBarTitleText(thisPage)
let onRoute = thisPage.onRoute
typeof onRoute === 'function' && onRoute(this[_query])
......@@ -60,7 +61,7 @@ class Router {
return pages[pages.length - size]
}
checkRouter (route, events) {
checkRouter(route, events) {
this[_query] = events || {}
const [_parent, _name, last_name] = route.split('.')
let name = route
......@@ -80,8 +81,7 @@ class Router {
const routerMapItem = this[_routerList].find(item => {
if (route.includes('/')) {
return item.url === route
}
else {
} else {
if (last_name) {
return item.parent === parent && item.name === last_name && item.subPages === name
} else {
......@@ -99,7 +99,7 @@ class Router {
}
}
/**跳转至H5 */
jumpH5 (url) {
jumpH5(url) {
wx.navigateTo({
url: `/pages/webView/webView?url=${encodeURIComponent(url)}`
})
......@@ -107,7 +107,7 @@ class Router {
/**页面跳转
*
*/
jump (e) {
jump(e) {
const item = e.currentTarget.dataset
this.go(item.url, item)
}
......@@ -115,7 +115,7 @@ class Router {
* 跳转到 tabBar 页面,并关闭其他所有非 tabBar 页面 ||
* 保留当前页面,跳转到应用内的某个页面。但是不能跳到 tabbar 页面。使用 $router.back() 可以返回到原页面。小程序中页面栈最多十层
*/
go (route, events) {
go(route, events) {
let { routerMapItem, query } = this.checkRouter(route, events)
console.log(routerMapItem)
if (routerMapItem.isTab) {
......@@ -130,14 +130,14 @@ class Router {
}
}
/**关闭所有页面,打开到应用内的某个页面 */
reLaunch (route, events) {
reLaunch(route, events) {
let { routerMapItem, query } = this.checkRouter(route, events)
wx.reLaunch({
url: `${routerMapItem.url}${query}`
})
}
/**关闭当前页面,跳转到应用内的某个页面。但是不允许跳转到 tabbar 页面。 */
redirectTo (route, events) {
redirectTo(route, events) {
let { routerMapItem, query } = this.checkRouter(route, events)
wx.redirectTo({
url: `${routerMapItem.url}${query}`
......@@ -146,7 +146,7 @@ class Router {
/**prevPageSize = 1
* 返回上prevPageSize页
* callBack返回上prevPageSize页对象 */
back (callBack, prevPageSize = 1) {
back(callBack, prevPageSize = 1) {
let prevPage = this.getPageInstance(Number(prevPageSize) + 1)
if (callBack && 'function' === typeof callBack) callBack(prevPage)
wx.navigateBack({
......@@ -155,18 +155,18 @@ class Router {
this.goHome()
})
}
goHome () {
goHome() {
let [index] = this[_routerList]
wx.reLaunch({
url: index.url
})
}
/**获取上一个页面传的数据 */
getData (callBack) {
getData(callBack) {
const data = this.getPageInstance().getOpenerEventChannel()
if (Object.keys(data).length !== 0) data.on('getData', res => callBack(res))
}
onRoute (fn) {
onRoute(fn) {
this[_routeHooks].push(fn)
return () => {
const i = list.indexOf(fn)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!