shop.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. // // store/modules/shop.js
  2. //
  3. // export default {
  4. // namespaced: true,
  5. // state: () => ({
  6. // shops: [{
  7. // "id": 1,
  8. // "name": "淮瑞咖啡-枫林店",
  9. // "address": "江西省南昌市经济开发区枫林大道江西财经大学店",
  10. // "keeperId": 5,
  11. // "username": null,
  12. // "keeperName": null,
  13. // "phone": null,
  14. // "email": null
  15. // },
  16. // {
  17. // "id": 2,
  18. // "name": "淮瑞咖啡-经开店",
  19. // "address": "江西省南昌市经济开发区双港西大街绿地悦公馆",
  20. // "keeperId": 1,
  21. // "username": null,
  22. // "keeperName": null,
  23. // "phone": null,
  24. // "email": null
  25. // }
  26. // ] // 保存店面数据的数组
  27. // }),
  28. // mutations: {
  29. // setShops(state, shops) {
  30. // state.shops = shops; // 更新店面数据
  31. // }
  32. // },
  33. // actions: {
  34. // //后端请求得到所有的店面的数据,保存入shops
  35. // async fetchShops({ commit }) {
  36. // return
  37. // try {
  38. // const response = await uni.request({
  39. // url: uni.$http.baseUrl + 'shop/selectAll',
  40. // method: 'GET',
  41. // header: {
  42. // 'content-type': 'application/json',
  43. // 'token': uni.$http.testToken
  44. // }
  45. // });
  46. // if (response.data && response.data.code === '200') {
  47. // // 如果请求成功并且返回的数据中包含 code 为 '200',则提交 mutation 更新店面数据
  48. // commit('setShops', response.data.data);
  49. // } else {
  50. // console.error('请求失败或返回的数据不符合预期');
  51. // }
  52. // } catch (error) {
  53. // console.error('请求失败:', error);
  54. // }
  55. // }
  56. // },
  57. // getters: {
  58. // getShopById: (state) => (id) => {
  59. // console.log(id);
  60. // return state.shops.find(shop => shop.id == id)
  61. // },
  62. // // getShopById(state , shopId,prarm3,prarm4){
  63. // // console.log(state);
  64. // // console.log(shopId);
  65. // // console.log(prarm3);
  66. // // console.log(prarm4);
  67. // // console.log('-----------');
  68. // // shopId=2
  69. // // // 从 shops 数组中查找与指定 id 相匹配的店面信息
  70. // // console.log(state.shops);
  71. // // let shops=state.shops
  72. // // for (let idx in shops) {
  73. // // console.log(idx);
  74. // // // console.log(shops[idx].id==shopId);
  75. // // console.log(shops[idx].id,shops[idx].id==shopId,shopId);
  76. // // if (shops[idx].id==shopId){
  77. // // let shop =shops[idx]
  78. // // return shop
  79. // // }
  80. // // }
  81. // // console.log(data);
  82. // // return data
  83. // // }
  84. // // getShopById: (state) => (shopId) => {
  85. // // console.log(shopId);
  86. // // // 从 shops 数组中查找与指定 id 相匹配的店面信息
  87. // // console.log(state.shops);
  88. // // let shops = state.shops;
  89. // // for (let idx in shops) {
  90. // // console.log(idx);
  91. // // console.log(shops[idx].id == shopId);
  92. // // console.log(shops[idx].id, shops[idx].id == shopId, shopId);
  93. // // if (shops[idx].id == shopId) {
  94. // // let shop = shops[idx];
  95. // // return shop;
  96. // // }
  97. // // }
  98. // // }
  99. // },
  100. // };