123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- // // store/modules/shop.js
- //
- // export default {
- // namespaced: true,
- // state: () => ({
- // shops: [{
- // "id": 1,
- // "name": "淮瑞咖啡-枫林店",
- // "address": "江西省南昌市经济开发区枫林大道江西财经大学店",
- // "keeperId": 5,
- // "username": null,
- // "keeperName": null,
- // "phone": null,
- // "email": null
- // },
- // {
- // "id": 2,
- // "name": "淮瑞咖啡-经开店",
- // "address": "江西省南昌市经济开发区双港西大街绿地悦公馆",
- // "keeperId": 1,
- // "username": null,
- // "keeperName": null,
- // "phone": null,
- // "email": null
- // }
- // ] // 保存店面数据的数组
- // }),
- // mutations: {
- // setShops(state, shops) {
- // state.shops = shops; // 更新店面数据
- // }
- // },
- // actions: {
- // //后端请求得到所有的店面的数据,保存入shops
- // async fetchShops({ commit }) {
- // return
- // try {
- // const response = await uni.request({
- // url: uni.$http.baseUrl + 'shop/selectAll',
- // method: 'GET',
- // header: {
- // 'content-type': 'application/json',
- // 'token': uni.$http.testToken
- // }
- // });
- // if (response.data && response.data.code === '200') {
- // // 如果请求成功并且返回的数据中包含 code 为 '200',则提交 mutation 更新店面数据
- // commit('setShops', response.data.data);
- // } else {
- // console.error('请求失败或返回的数据不符合预期');
- // }
- // } catch (error) {
- // console.error('请求失败:', error);
- // }
- // }
- // },
- // getters: {
- // getShopById: (state) => (id) => {
- // console.log(id);
- // return state.shops.find(shop => shop.id == id)
- // },
- // // getShopById(state , shopId,prarm3,prarm4){
- // // console.log(state);
- // // console.log(shopId);
- // // console.log(prarm3);
- // // console.log(prarm4);
- // // console.log('-----------');
- // // shopId=2
- // // // 从 shops 数组中查找与指定 id 相匹配的店面信息
- // // console.log(state.shops);
- // // let shops=state.shops
- // // for (let idx in shops) {
- // // console.log(idx);
- // // // console.log(shops[idx].id==shopId);
- // // console.log(shops[idx].id,shops[idx].id==shopId,shopId);
- // // if (shops[idx].id==shopId){
- // // let shop =shops[idx]
- // // return shop
- // // }
- // // }
- // // console.log(data);
- // // return data
- // // }
- // // getShopById: (state) => (shopId) => {
- // // console.log(shopId);
- // // // 从 shops 数组中查找与指定 id 相匹配的店面信息
- // // console.log(state.shops);
- // // let shops = state.shops;
- // // for (let idx in shops) {
- // // console.log(idx);
- // // console.log(shops[idx].id == shopId);
- // // console.log(shops[idx].id, shops[idx].id == shopId, shopId);
- // // if (shops[idx].id == shopId) {
- // // let shop = shops[idx];
- // // return shop;
- // // }
- // // }
- // // }
- // },
- // };
|