index.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. let myPro = require("../../../utils/wxRequest.js");
  2. let util = require("../../../utils/util.js");
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. imgUrl: getApp().globalData.imgUrl,
  9. begin_at: '',
  10. end_at: '',
  11. status: 1, //
  12. is_ziti: 1,
  13. info: null, // 店铺详情
  14. showBegin: false, // 开店 时间pop
  15. currentBegin: '',
  16. showEnd: false, // 闭店 时间pop
  17. currentEnd: '',
  18. is_delivery: 1 // 1允许配送 0不允许
  19. },
  20. /**
  21. * 生命周期函数--监听页面加载
  22. */
  23. onLoad: function (options) {
  24. let that = this;
  25. },
  26. /**
  27. * 生命周期函数--监听页面初次渲染完成
  28. */
  29. onReady: function () {
  30. },
  31. /**
  32. * 生命周期函数--监听页面显示
  33. */
  34. onShow: function () {
  35. var that = this
  36. that.getShopInfo();
  37. },
  38. /**
  39. * 生命周期函数--监听页面隐藏
  40. */
  41. onHide: function () {
  42. },
  43. /**
  44. * 生命周期函数--监听页面卸载
  45. */
  46. onUnload: function () {
  47. },
  48. /**
  49. * 页面相关事件处理函数--监听用户下拉动作
  50. */
  51. onPullDownRefresh: function () {
  52. },
  53. /**
  54. * 页面上拉触底事件的处理函数
  55. */
  56. onReachBottom: function () {
  57. },
  58. onPageScroll: function (event) {
  59. // Do something when page scroll
  60. },
  61. onResize: function () {
  62. // Do something when page resize
  63. },
  64. // 获取店铺信息
  65. getShopInfo(){
  66. let that = this;
  67. myPro.wxRequest("store/info","GET",{}).then(res=>{
  68. that.setData({
  69. info: res.result,
  70. begin_at: res.result.begin_at,
  71. end_at: res.result.end_at,
  72. status: res.result.status,
  73. is_ziti: res.result.is_ziti,
  74. is_delivery: res.result.is_delivery
  75. });
  76. }).catch(err=>{
  77. console.log('报错信息',err)
  78. wx.showToast({
  79. title: err,
  80. icon: "none"
  81. });
  82. });
  83. },
  84. // 去个人资料
  85. goMyIndex(){
  86. wx.reLaunch({
  87. url: '/pages/user/index/index'
  88. })
  89. },
  90. // 是否营业
  91. onChangeSell(event){
  92. let that = this;
  93. that.setData({
  94. status: event.detail,
  95. });
  96. that.editShop()
  97. },
  98. // 是否自提
  99. onChangeZiti(event){
  100. let that = this;
  101. that.setData({
  102. is_ziti: event.detail,
  103. });
  104. that.editShop()
  105. },
  106. // 是否允许配送
  107. onChangeDelivery(event){
  108. let that = this;
  109. that.setData({
  110. is_delivery: event.detail,
  111. });
  112. that.editShop()
  113. },
  114. // 去门店订单
  115. goShopOrder(event){
  116. let that = this;
  117. let status = event.currentTarget.dataset.status
  118. // console.log('订单状态',event)
  119. wx.navigateTo({
  120. url: '/pages/shopRole/order/index?status='+ status
  121. })
  122. },
  123. // 开店时间
  124. beginTimeFun(){
  125. let that = this;
  126. that.setData({
  127. showBegin: true
  128. })
  129. },
  130. confirmBeginTime(event){
  131. // console.log('开始时间',event)
  132. let that = this;
  133. that.setData({
  134. begin_at: event.detail,
  135. showBegin: false
  136. })
  137. that.editShop()
  138. },
  139. closeBeginTimePop(){
  140. let that = this;
  141. that.setData({
  142. showBegin: false
  143. })
  144. },
  145. // 闭店时间
  146. endTimeFun(){
  147. let that = this;
  148. that.setData({
  149. showEnd: true
  150. })
  151. },
  152. confirmEndTime(event){
  153. // console.log('闭店时间',event)
  154. let that = this;
  155. that.setData({
  156. end_at: event.detail,
  157. showEnd: false
  158. })
  159. that.editShop()
  160. },
  161. closeEndTimePop(){
  162. let that = this;
  163. that.setData({
  164. showEnd: false
  165. })
  166. },
  167. // 编辑店铺信息
  168. editShop(){
  169. let that = this;
  170. let params = {
  171. status: that.data.status,
  172. is_ziti: that.data.is_ziti,
  173. begin_at: that.data.begin_at,
  174. end_at: that.data.end_at,
  175. is_delivery: that.data.is_delivery
  176. };
  177. myPro.wxRequest("store/editInfo","POST",params).then(res=>{
  178. wx.showToast({
  179. title: res.msg,
  180. icon: "none"
  181. });
  182. // 重新获取详情
  183. that.getShopInfo()
  184. }).catch(err=>{
  185. console.log('报错信息',err);
  186. wx.showToast({
  187. title: err,
  188. icon: "none"
  189. });
  190. })
  191. },
  192. // 提现
  193. goCashOut(){
  194. wx.navigateTo({
  195. url: '/pages/shopRole/cashout/index'
  196. })
  197. },
  198. // 提现记录
  199. goCashOutlog(){
  200. wx.navigateTo({
  201. url: '/pages/shopRole/cashoutlog/index'
  202. })
  203. },
  204. // 优惠券使用统计
  205. goShopCoupons(){
  206. let that = this;
  207. wx.navigateTo({
  208. url: '/pages/shopRole/usedcoupons/index'
  209. })
  210. },
  211. // 设置营业时间
  212. goBusinessTime(){
  213. let that = this;
  214. wx.navigateTo({
  215. url: "/pages/shopRole/businesstime/list/index"
  216. })
  217. }
  218. })