123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- const Parse = getApp().Parse;
- const company = getApp().globalData.company
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- storeId: '',
- current: null,
- store: null,
- activeColor:''
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: async function (options) {
- this.setData({
- activeColor:getApp().globalData.activeColor || '#229293'
- })
- let storeID = options.store
- await this.getShopStore()
- await this.getBindStore()
- },
- // 获取所有店铺信息
- getShopStore: async function () {
- let Store = new Parse.Query('ShopStore')
- Store.notEqualTo('isDeleted', "true")
- Store.equalTo('company', company)
- Store.equalTo('type', 'shop')
- Store.descending('createdAt')
- let store = await Store.find()
- let list = []
- store.forEach(val => {
- val = val.toJSON()
- list.push(val)
- })
- let current = list.filter(val => {
- return val.objectId == this.data.storeID
- })[0]
- this.setData({
- store: list,
- current: current
- })
- },
- // 获取当前绑定的店铺
- getBindStore: async function () {
- let storeID = wx.getStorageSync('storeID');
- let Store = new Parse.Query('ShopStore')
- let store = await Store.get(storeID)
- let storeJSON = store.toJSON()
- this.setData({
- current: storeJSON
- })
- },
- // 点击店铺绑定
- bindStore(e) {
- let id = e.currentTarget.dataset.id
- wx.setStorageSync('storeID', id);
- wx.navigateBack({
- delta: 1,
- });
- setTimeout(() => {
- wx.showToast({
- title: '选择完毕',
- icon: 'success',
- duration: 1500,
- });
- }, 200)
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|