index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. <template>
  2. <view>
  3. <z-navbar title="搜索" back></z-navbar>
  4. <view class="search_top flex-n fac fjc">
  5. <view class="search_top_in flex-n fac">
  6. <view class="search_top_icon ml-35 mr-20 iconfont iconjuxing5"></view>
  7. <z-input class="flex-1 mr-35" placeholder="请输入关键字" align="left" v-model="searchText"></z-input>
  8. </view>
  9. </view>
  10. <scroll-view scroll-y class="search_content">
  11. <view v-if="once" class="flex-w fac">
  12. <checkbox-group class="mt-20" @change="checkboxAllChange">
  13. <label class="ml-20" style="font-size: 28rpx;">
  14. <checkbox value="checkedall" :checked="checkedAll" color="#2d8cf0"
  15. style="transform:scale(0.7)" />全部
  16. </label>
  17. </checkbox-group>
  18. <checkbox-group class="mt-20" @change="checkboxChange">
  19. <label v-for="(item,index) in houseTypeList" :key="index" class="ml-20" style="font-size: 28rpx;">
  20. <checkbox :value="item.houseTypeId" :checked="item.checked" color="#2d8cf0"
  21. style="transform:scale(0.7)" />{{item.houseTypeName}}
  22. </label>
  23. </checkbox-group>
  24. <z-button class="mt-80" @click="backSearch">确定筛选</z-button>
  25. </view>
  26. <view class="search_nocontent" v-if="!once&&list.length==0">
  27. <image class="search_nocontent_img" mode="widthFix" src="../../static/nocontent.png"></image>
  28. <view class="search_nocontent_notext">未搜索到相关结果</view>
  29. </view>
  30. <view v-else>
  31. <template v-if="type==0">
  32. <z-cell arrow v-for="(item,index) in list" :key="index" @click.native="gotoRemind(item.id)">
  33. <view class="search_item">
  34. <view class="flex-n fac">
  35. <view>{{item.customName}}</view>
  36. <view class="ml-36">{{item.phone}}</view>
  37. <view class="ml-36">{{item.wantDate}}</view>
  38. </view>
  39. <view class="flex-n fac">
  40. <view class="nowarp">{{item.wantHouseContent}}</view>
  41. </view>
  42. </view>
  43. </z-cell>
  44. </template>
  45. <template v-else-if="type==1">
  46. <z-cell arrow v-for="(item,index) in list" :key="index" @click.native="gotoOrder(item.id)">
  47. <view class="search_item">
  48. <view class="flex-n fac">
  49. <view>{{item.orderDate}}</view>
  50. <view class="ml-36">{{item.activityBeginTime}}-{{item.activityEndTime}}</view>
  51. </view>
  52. <view class="flex-n fac">
  53. <view class="nowarp">{{item.customName}}</view>
  54. <view class="ml-20 nowarp">{{item.houseName}}</view>
  55. <view class="ml-20 line-1">{{item.packageName}}{{item.paycontent}}</view>
  56. </view>
  57. </view>
  58. </z-cell>
  59. </template>
  60. <template v-else>
  61. <z-cell arrow v-for="(item,index) in list" :key="index" @click.native="gotoSettlement(item.id)">
  62. <view class="search_item">
  63. <view class="flex-n fac">
  64. <view>{{item.orderDate}}</view>
  65. <view class="ml-36">{{item.activityBeginTime}}-{{item.activityEndTime}}</view>
  66. </view>
  67. <view class="flex-n fac">
  68. <view class="nowarp">{{item.customName}}</view>
  69. <view class="ml-20 nowarp">{{item.houseName}}</view>
  70. <view class="ml-20 line-1">{{item.packageName}}{{item.paycontent}}</view>
  71. </view>
  72. </view>
  73. </z-cell>
  74. </template>
  75. </view>
  76. </scroll-view>
  77. </view>
  78. </template>
  79. <script>
  80. const app = getApp({
  81. allowDefault: true
  82. });
  83. export default {
  84. data() {
  85. return {
  86. searchText: '',
  87. searchType: 0,
  88. nodata: false,
  89. type: 0, //0咨询提醒,1预定提醒,2预定查询
  90. list: [],
  91. houseTypeList: [],
  92. checkedAll: false,
  93. checkedList: [],
  94. once: true, //第一次进入
  95. }
  96. },
  97. onLoad(option) {
  98. this.type = option.type;
  99. this.gethouseTypeList();
  100. },
  101. watch: {
  102. searchText(newval, oldval) {
  103. this.once = false;
  104. if (this.type == 0) {
  105. this.searchRemind(newval);
  106. } else if (this.type == 1 || this.type == 2) {
  107. this.searchOrder(newval);
  108. this.searchType = 0;
  109. } else {
  110. this.searchOrder(newval);
  111. this.searchType = 1;
  112. }
  113. }
  114. },
  115. methods: {
  116. backSearch() {
  117. if (this.type == 1) {
  118. var pages = getCurrentPages();
  119. var prevPage = pages[pages.length - 2]; //上一个页面
  120. prevPage.$vm.backState = false;
  121. prevPage.$vm.tabInfo(); //重点$vm
  122. }
  123. uni.setStorage({
  124. key: 'searchField',
  125. data: this.checkedList
  126. })
  127. uni.navigateBack({
  128. delta: 1
  129. })
  130. },
  131. gethouseTypeList() {
  132. this.$axios.get("app/house/houseTypeListByStoreId/" + uni.getStorageSync('storeId')).then(res => {
  133. console.log('场地类型', res)
  134. this.houseTypeList = res.data.list;
  135. // if(this.$root.getStorage('checkedCities')){
  136. // this.checkedList= this.$root.getStorage('checkedCities');
  137. // }
  138. uni.getStorage({
  139. key: 'searchField',
  140. success: (res) => {
  141. console.log(res.data)
  142. this.checkedList = res.data;
  143. for (var j in this.checkedList) {
  144. for (var i in this.houseTypeList) {
  145. var item = this.houseTypeList[i];
  146. if (item.houseTypeId == this.checkedList[j])
  147. this.$set(item, 'checked', true)
  148. }
  149. }
  150. }
  151. })
  152. }).catch(err => {
  153. console.log(err)
  154. })
  155. },
  156. checkboxAllChange: function(e) {
  157. console.log(e.detail.value.length)
  158. if (e.detail.value.length > 0) {
  159. for (var i in this.houseTypeList) {
  160. var item = this.houseTypeList[i];
  161. this.$set(item, 'checked', true)
  162. }
  163. this.checkedAll = true;
  164. } else {
  165. for (var i in this.houseTypeList) {
  166. var item = this.houseTypeList[i];
  167. this.$set(item, 'checked', false)
  168. }
  169. console.log(this.houseTypeList)
  170. this.checkedAll = false;
  171. }
  172. },
  173. checkboxChange: function(e) {
  174. this.checkedList = e.detail.value;
  175. var items = this.houseTypeList,
  176. values = e.detail.value;
  177. for (var i = 0, lenI = items.length; i < lenI; ++i) {
  178. const item = items[i]
  179. if (values.includes(item.houseTypeId)) {
  180. this.$set(item, 'checked', true)
  181. } else {
  182. this.$set(item, 'checked', false)
  183. }
  184. }
  185. if (e.detail.value.length == this.houseTypeList.length) {
  186. this.checkedAll = true;
  187. } else {
  188. this.checkedAll = false;
  189. }
  190. console.log(e.detail.value)
  191. },
  192. searchRemind(searchText) {
  193. this.$axios.post('app/preUserAsk/getFindAskList', {
  194. "searchText": searchText,
  195. "storeId": uni.getStorageSync('storeId')
  196. }).then(res => {
  197. console.log(res)
  198. this.list = res.data.list;
  199. for (var i in this.list) {
  200. var wantHouseContent = '';
  201. for (var j in this.list[i].wantHouse) {
  202. wantHouseContent += this.list[i].wantHouse[j].houseName + '、';
  203. }
  204. if (wantHouseContent.length > 0) {
  205. wantHouseContent = wantHouseContent.substring(0, wantHouseContent.length - 1);
  206. }
  207. this.list[i].wantHouseContent = wantHouseContent;
  208. }
  209. }).catch(err => {
  210. console.log(err)
  211. })
  212. },
  213. searchOrder(searchText) {
  214. this.$axios.post('app/order/findOrderList', {
  215. "searchText": searchText,
  216. "storeId": uni.getStorageSync('storeId'),
  217. "searchType": this.searchType
  218. }).then(res => {
  219. console.log(res)
  220. this.list = res.data.list;
  221. for (var i in this.list) {
  222. var paycontent = '';
  223. if (this.list[i].mainPayType == '03') {
  224. paycontent += '包场地'
  225. if (this.list[i].payTypes.length > 1) {
  226. paycontent += '('
  227. }
  228. }
  229. for (var j in this.list[i].payTypes) {
  230. if (this.list[i].payTypes[j].payTypeCode == '01') {
  231. paycontent += (this.list[i].payTypes[j].orderCount || 0) + '人、'
  232. }
  233. if (this.list[i].payTypes[j].payTypeCode == '02') {
  234. paycontent += (this.list[i].payTypes[j].orderCount || 0) + '桌、'
  235. }
  236. }
  237. if (paycontent.length > 0) {
  238. paycontent = paycontent.substring(0, paycontent.length - 1);
  239. }
  240. if (this.list[i].mainPayType == '03' && this.list[i].payTypes.length > 1) {
  241. paycontent += ')'
  242. }
  243. this.list[i].paycontent = paycontent.length > 0 ? ('[' + paycontent + ']') : ''
  244. }
  245. }).catch(err => {
  246. console.log(err)
  247. })
  248. },
  249. gotoRemind(id) {
  250. uni.navigateTo({
  251. url: '../remind/detail/index?id=' + id
  252. })
  253. },
  254. gotoOrder(id) {
  255. uni.navigateTo({
  256. url: '../book/detail/index?id=' + id
  257. })
  258. },
  259. gotoSettlement(id) {
  260. uni.navigateTo({
  261. url: '../settlement/detail/index?type=' + this.searchType + '&id=' + id
  262. })
  263. }
  264. }
  265. }
  266. </script>
  267. <style lang="scss" scoped>
  268. .search_top {
  269. height: 130rpx;
  270. background: #FAFBFF;
  271. .search_top_in {
  272. width: 690rpx;
  273. height: 84rpx;
  274. background: #E7E8EA;
  275. border-radius: 4rpx;
  276. .search_top_icon {
  277. width: 34rpx;
  278. height: 34rpx;
  279. color: #333333;
  280. }
  281. }
  282. }
  283. .search_content {
  284. height: calc(100vh - 214rpx - var(--status-bar-height));
  285. background: white;
  286. .search_nocontent {
  287. text-align: center;
  288. .search_nocontent_img {
  289. width: 448rpx;
  290. margin-top: 304rpx;
  291. }
  292. .search_nocontent_notext {
  293. color: #999999;
  294. font-size: 30rpx;
  295. margin-top: 65rpx;
  296. }
  297. }
  298. .search_item {
  299. font-size: 28rpx;
  300. color: #333333;
  301. text-align: left !important;
  302. width: 656rpx;
  303. padding: 20rpx 0;
  304. }
  305. }
  306. </style>