功能:完善门店能力与用户安全配置
This commit is contained in:
@@ -6,6 +6,10 @@ const navigation = require('../../utils/navigation')
|
||||
const { buildProductCard } = require('../../utils/product')
|
||||
const { runWithLoading } = require('../../utils/loading')
|
||||
|
||||
/**
|
||||
* wishlist page logic.
|
||||
* Call guide: page data drives the WXML template, and each method is called by user events or lifecycle callbacks.
|
||||
*/
|
||||
Page({
|
||||
data: {
|
||||
loading: false,
|
||||
@@ -13,6 +17,10 @@ Page({
|
||||
wishlist: []
|
||||
},
|
||||
|
||||
/**
|
||||
* `onShow` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
onShow() {
|
||||
this.loadWishlist()
|
||||
},
|
||||
@@ -24,6 +32,10 @@ Page({
|
||||
loading: isLoggedIn
|
||||
})
|
||||
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!isLoggedIn) {
|
||||
this.cartProductIdSet = new Set()
|
||||
this.setData({
|
||||
@@ -63,6 +75,10 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* `normalizeId` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
normalizeId(value) {
|
||||
return value === undefined || value === null ? '' : String(value)
|
||||
},
|
||||
@@ -83,6 +99,10 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* `markCardInCart` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
markCardInCart(card, idSet) {
|
||||
return {
|
||||
...card,
|
||||
@@ -90,8 +110,16 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* `markWishlistProductInCart` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
markWishlistProductInCart(productId) {
|
||||
const normalizedId = this.normalizeId(productId)
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!normalizedId) {
|
||||
return
|
||||
}
|
||||
@@ -114,12 +142,24 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleOpenAuth` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleOpenAuth() {
|
||||
navigation.openAuth('/pages/wishlist/index')
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleProductSelect` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleProductSelect(event) {
|
||||
const product = event.detail || {}
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!product.id) {
|
||||
return
|
||||
}
|
||||
@@ -132,6 +172,10 @@ Page({
|
||||
async handleQuickAdd(event) {
|
||||
const product = event.detail || {}
|
||||
const productId = this.normalizeId(product.id)
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!productId) {
|
||||
return
|
||||
}
|
||||
@@ -174,6 +218,10 @@ Page({
|
||||
|
||||
async handleRemove(event) {
|
||||
const productId = event.currentTarget.dataset.productId
|
||||
/**
|
||||
* `if` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
if (!productId) {
|
||||
return
|
||||
}
|
||||
@@ -198,6 +246,10 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* `handleBack` page method. Use this from WXML event bindings or lifecycle hooks.
|
||||
* Call guide: read or update page data with `this.setData(...)` inside the method when state changes.
|
||||
*/
|
||||
handleBack() {
|
||||
navigation.goBack('/pages/profile/index')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user