Commit 6352bf20 by 张立顺

合并代码

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