detail.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <template>
  2. <view class="content">
  3. <view class="top-v" v-show="storeInfo"><text class="storeName">预约【{{ storeInfo.name }}】</text><text class="moreStore" @click="toMoreStore">切换门店</text></view>
  4. <view class="info-v">
  5. <view class="title">
  6. |请选择预约日期
  7. </view>
  8. <view v-if="dateArr && dateArr.length > 0" class="list-v">
  9. <view @click="dateClick(index)" v-for="(item, index) in dateArr" :key="index" :class="[dateIndex==index?'activeItem':'item-v']">
  10. <view>{{item.week}}</view>
  11. <view>{{ item.date }}</view>
  12. </view>
  13. </view>
  14. <none v-if="!dateArr.length" :isLoading="false" :custom-style="{ padding: '30px 10px' }" tips="暂无可预约日期"></none>
  15. </view>
  16. <view class="info-v">
  17. <view class="title">
  18. |请选择预约时段
  19. </view>
  20. <view v-if="timeArr && timeArr.length > 0" class="list-v">
  21. <view @click="timeClick(index)" v-for="(item, index) in timeArr" :key="index" :class="[timeIndex==index?'activeItem' : (bookable.indexOf(item.time) >= 0 ? 'item-v' : 'disable') ]">
  22. <view>{{ item.time }}</view>
  23. </view>
  24. </view>
  25. <none v-if="!timeArr.length" :isLoading="false" :custom-style="{ padding: '30rpx 10rpx' }" tips="暂无可预约时段"></none>
  26. </view>
  27. <view class="btn" @click="doSubmit">确定预约</view>
  28. </view>
  29. </template>
  30. <script>
  31. import * as BookApi from '@/api/book'
  32. import * as SettingApi from '@/api/setting'
  33. import None from '@/components/none'
  34. export default {
  35. components: {
  36. None
  37. },
  38. data() {
  39. return {
  40. // 预约项目ID
  41. bookId: null,
  42. // 当前预约详情
  43. bookInfo: null,
  44. dateArr: [ { week: '星期六', date : '8月17号' }, { week: '星期日', date : '8月18号' }],
  45. timeArr: [ '09:00-12:00', '14:00-15:00' ],
  46. dateIndex: 0,
  47. timeIndex: 100000,
  48. storeInfo: null,
  49. bookable: [],
  50. isCheck: false
  51. }
  52. },
  53. onLoad(options) {
  54. // 记录预约ID
  55. this.bookId = options.bookId;
  56. // 获取预约详情
  57. this.getBookDetail();
  58. },
  59. onShow() {
  60. uni.removeStorageSync('bookData');
  61. this.getStoreInfo();
  62. this.dateIndex = 0;
  63. this.timeIndex = 100000;
  64. },
  65. methods: {
  66. // 获取预约项目详情
  67. getBookDetail() {
  68. const app = this;
  69. app.isLoading = true;
  70. BookApi.detail(app.bookId)
  71. .then(result => {
  72. app.bookInfo = result.data.bookInfo;
  73. app.dateArr = app.bookInfo.dateList;
  74. app.timeArr = app.bookInfo.timeList;
  75. app.dateClick(app.dateIndex);
  76. })
  77. .finally(() => app.isLoading = false)
  78. },
  79. // 切换门店
  80. toMoreStore() {
  81. this.$navTo('pages/location/index');
  82. },
  83. // 获取店铺详情
  84. getStoreInfo() {
  85. const app = this;
  86. SettingApi.storeDetail()
  87. .then(result => {
  88. app.storeInfo = result.data.storeInfo;
  89. })
  90. },
  91. // 确定预约
  92. doSubmit() {
  93. let app = this;
  94. if (!app.isCheck) {
  95. app.$toast("请选择预约时间!");
  96. return false;
  97. }
  98. uni.showModal({
  99. title: '提示',
  100. content: '确定预约【'+app.storeInfo.name+'】吗?',
  101. success: function (res) {
  102. if (res.confirm) {
  103. let dates = app.bookInfo.serviceDates.split(",");
  104. let week = app.dateArr[app.dateIndex].week;
  105. let data = { bookId: app.bookId, week: week, date : dates[app.dateIndex], time: app.timeArr[app.timeIndex].time };
  106. uni.setStorageSync('bookData', data);
  107. app.$navTo('pages/book/submit');
  108. }
  109. }
  110. });
  111. },
  112. // 选择时段
  113. timeClick(index) {
  114. const app = this;
  115. if (app.bookable.indexOf(app.timeArr[index].time) < 0) {
  116. return false;
  117. }
  118. app.timeIndex = index;
  119. app.isCheck = true;
  120. },
  121. // 选择日期
  122. dateClick(index) {
  123. const app = this;
  124. app.dateIndex = index;
  125. app.timeIndex = 100000;
  126. let dates = app.bookInfo.serviceDates.split(",");
  127. let times = app.timeArr;
  128. BookApi.bookable({ bookId: app.bookId, date: dates[app.dateIndex], time: '' })
  129. .then(result => {
  130. if (result.data) {
  131. app.bookable = result.data;
  132. } else {
  133. app.bookable = [];
  134. }
  135. })
  136. }
  137. }
  138. }
  139. </script>
  140. <style lang="scss" scoped>
  141. .content {
  142. .top-v {
  143. margin: 20rpx;
  144. .storeName {
  145. font-weight: bold;
  146. font-size: 32rpx;
  147. }
  148. .moreStore {
  149. float: right;
  150. color: $fuint-theme;
  151. border: 1rpx solid $fuint-theme;
  152. padding: 6rpx;
  153. border-radius: 20rpx;
  154. font-size: 24rpx;
  155. }
  156. }
  157. padding-bottom: 50rpx;
  158. }
  159. .getInfo-v {
  160. background-color: #fff;
  161. padding: 50rpx 30rpx;
  162. border-radius: 20rpx;
  163. width: 600rpx;
  164. .getInfo-btn{
  165. background-color: $fuint-theme;
  166. color: #fff;
  167. padding: 20rpx;
  168. border-radius: 10rpx;
  169. margin-top: 30rpx;
  170. text-align: center;
  171. }
  172. }
  173. .btn {
  174. margin: 20rpx auto;
  175. background-color: $fuint-theme;
  176. padding: 20rpx;
  177. border-radius: 40rpx;
  178. text-align: center;
  179. color: #fff;
  180. width: 680rpx;
  181. font-size: 30rpx;
  182. margin-top: 50rpx;
  183. }
  184. .info-v {
  185. padding: 20rpx;
  186. background-color: #fff;
  187. margin-bottom: 20rpx;
  188. .title {
  189. font-weight: bold;
  190. color: $fuint-theme;
  191. }
  192. .list-v {
  193. padding: 20rpx;
  194. display: flex;
  195. flex-wrap: wrap;
  196. .item-v {
  197. border-radius: 12rpx;
  198. font-size: 30rpx;
  199. margin-top: 10rpx;
  200. margin-left: 10rpx;
  201. font-weight: bold;
  202. width: 30%;
  203. border: 1rpx solid #ccc;
  204. text-align: center;
  205. padding: 20rpx;
  206. }
  207. .activeItem {
  208. font-size: 30rpx;
  209. border-radius: 12rpx;
  210. margin-top: 10rpx;
  211. margin-left: 10rpx;
  212. width: 30%;
  213. font-weight: bold;
  214. background-color: $fuint-theme;
  215. border: 1rpx solid #ccc;
  216. color: #fff;
  217. text-align: center;
  218. padding: 20rpx;
  219. }
  220. .disable {
  221. border-radius: 12rpx;
  222. font-size: 30rpx;
  223. margin-top: 10rpx;
  224. margin-left: 10rpx;
  225. font-weight: bold;
  226. width: 30%;
  227. border: 1rpx solid #ccc;
  228. text-align: center;
  229. color: white !important;
  230. background-color: rgb(188, 188, 188) !important;
  231. padding: 20rpx;
  232. }
  233. }
  234. }
  235. </style>