selectTechnical.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  1. <template>
  2. <view class="page">
  3. <scroll-view class="scrollList" scroll-y :scroll-into-view="scrollViewId" :style="{height:winHeight+'px'}">
  4. <view class="search-bar">
  5. <view class="search-bar-form">
  6. <view class="search-bar-box">
  7. <!-- <icon class="icon-search-in-box" type="search" size="16"></icon> -->
  8. <input confirm-type="search" class="search-bar-input" placeholder="输入关键词"
  9. placeholder-class="phcolor" :value="inputVal" :focus="inputShowed" @input="inputTyping" />
  10. <view class="icon-clear" v-if="inputVal" @tap="clearInput">
  11. <!-- #ifdef APP-PLUS || MP -->
  12. <icon type="clear" :size="15"></icon>
  13. <!-- #endif -->
  14. <!-- #ifdef H5 -->
  15. <tui-icon name="close-fill" :size="16" color="#bfbfbf"></tui-icon>
  16. <!-- #endif -->
  17. </view>
  18. </view>
  19. <label class="search-bar-label" v-if="!inputShowed" @tap="showInput">
  20. <!-- <icon class="icon-search" type="search" size="16"></icon> -->
  21. <view class="search-bar-text">输入关键词</view>
  22. </label>
  23. </view>
  24. </view>
  25. <view class="tui-list search-result" v-if="inputShowed">
  26. <view class="tui-list-cell" hover-class="tui-list-cell-hover" v-for="(item,index) in searchResult"
  27. :key="index" @tap="selectTechnical" :data-uuid="item" :hover-stay-time='150'>
  28. <view class="tui-list-cell-navigate">
  29. {{item}}
  30. </view>
  31. </view>
  32. </view>
  33. <view v-if="!inputVal">
  34. <view class="tui-list city-list" >
  35. <block v-if="lists.length>0">
  36. <view class="tui-list-cell" hover-class="tui-list-cell-hover" v-for="(item,index) in lists"
  37. :key="index" @tap="selectTechnical" :data-uuid="item.uuid" :hover-stay-time='150'>
  38. <view class="tui-list-cell-navigate">
  39. {{item.title}}
  40. </view>
  41. </view>
  42. </block>
  43. <block v-else>
  44. <view style="text-align: center;color: #999;">您的店铺还没有{{lang.technical}}!</view>
  45. </block>
  46. </view>
  47. </view>
  48. </scroll-view>
  49. </view>
  50. </template>
  51. <script>
  52. export default {
  53. data() {
  54. return {
  55. lang: {},
  56. sid: 0,
  57. orderid: 0,
  58. lists: [],
  59. titleHeight: 0, // 索引二字距离窗口顶部的高度
  60. indexBarHeight: 0, // 索引表高度
  61. indexBarItemHeight: 0, // 索引表子项的高度
  62. scrollViewId: '', // scroll-view滚动到的子元素的id
  63. winHeight: 0,
  64. inputShowed: false, // 输入框是否显示
  65. inputVal: '', // 搜索框输入的内容
  66. searchResult: [], // 搜索的结果
  67. }
  68. },
  69. onLoad: function(options) {
  70. const _this = this;
  71. _this.orderid = options.id;
  72. _this.sid = options.sid;
  73. _this.$request.get('Lang.getlang').then(res => {
  74. if (res.errno == 0) {
  75. _this.lang = res.data;
  76. }
  77. });
  78. _this.$request.post('technical.list', {
  79. sid: _this.sid
  80. }).then(res => {
  81. _this.lists = res.data.data;
  82. });
  83. setTimeout(() => {
  84. uni.getSystemInfo({
  85. success: function(res) {
  86. let winHeight = res.windowHeight
  87. let barHeight = winHeight - uni.upx2px(204);
  88. _this.winHeight = winHeight;
  89. _this.indexBarHeight = barHeight;
  90. _this.indexBarItemHeight = barHeight / 25;
  91. _this.titleHeight = uni.upx2px(132);
  92. }
  93. })
  94. }, 50)
  95. },
  96. methods: {
  97. showInput() {
  98. this.inputShowed = true
  99. },
  100. clearInput() {
  101. this.inputVal = "";
  102. this.inputShowed = false;
  103. this.searchResult = [];
  104. uni.hideKeyboard() //强行隐藏键盘
  105. },
  106. inputTyping(e) {
  107. this.inputVal = e.detail.value;
  108. this.searchCity()
  109. },
  110. // 搜索城市
  111. searchCity() {
  112. let result = []
  113. this.lists.forEach((item1, index1) => {
  114. item1.data.forEach((item2, index2) => {
  115. if (item2.keyword.indexOf(this.inputVal.toLocaleUpperCase()) !== -1) {
  116. result.push(item2.cityName)
  117. }
  118. })
  119. })
  120. this.searchResult = result
  121. },
  122. // 选择城市
  123. selectTechnical(e) {
  124. const _this = this;
  125. let uuid = e.currentTarget.dataset.uuid;
  126. _this.$request.post('order.staff', {
  127. id: _this.orderid,
  128. identity:'technical',
  129. uuid: uuid
  130. }).then(res => {
  131. uni.navigateBack({
  132. delta: 1
  133. })
  134. });
  135. }
  136. },
  137. /**
  138. * 页面相关事件处理函数--监听用户下拉动作
  139. */
  140. onPullDownRefresh: function() {
  141. setTimeout(() => {
  142. uni.stopPullDownRefresh()
  143. }, 200);
  144. },
  145. }
  146. </script>
  147. <style>
  148. page {
  149. height: 100%;
  150. overflow: hidden;
  151. }
  152. .page {
  153. height: 100%;
  154. overflow: hidden;
  155. }
  156. .scrollList {
  157. flex: 1;
  158. }
  159. .search-bar {
  160. display: flex;
  161. align-items: center;
  162. position: relative;
  163. padding: 27rpx 30rpx 35rpx;
  164. background-color: #fff;
  165. }
  166. .search-bar-form {
  167. flex: 1;
  168. position: relative;
  169. border-radius: 32rpx;
  170. background: #f2f5f7;
  171. }
  172. .search-bar-box {
  173. display: flex;
  174. align-items: center;
  175. position: relative;
  176. padding-left: 20rpx;
  177. padding-right: 20rpx;
  178. height: 64rpx;
  179. z-index: 1;
  180. }
  181. .search-bar-input {
  182. line-height: normal;
  183. width: 100%;
  184. padding-left: 20rpx;
  185. font-size: 30rpx;
  186. color: #333;
  187. }
  188. .phcolor {
  189. font-size: 30rpx;
  190. }
  191. .icon-clear {
  192. height: 38rpx;
  193. }
  194. .icon-clear .tui-icon-class {
  195. display: block
  196. }
  197. .search-bar-label {
  198. height: 64rpx;
  199. display: flex;
  200. justify-content: center;
  201. align-items: center;
  202. position: absolute;
  203. top: 0;
  204. right: 0;
  205. bottom: 0;
  206. left: 0;
  207. z-index: 2;
  208. border-radius: 32rpx;
  209. color: #ccc;
  210. background: #f2f5f7;
  211. }
  212. .icon-search {
  213. position: relative;
  214. height: 26rpx;
  215. margin-right: 20rpx;
  216. font-size: inherit;
  217. }
  218. .search-bar-text {
  219. font-size: 30rpx;
  220. line-height: 32rpx;
  221. }
  222. .cancel-btn {
  223. padding-left: 30rpx;
  224. }
  225. .search-result::before {
  226. display: none;
  227. }
  228. .search-result::after {
  229. display: none;
  230. }
  231. .tui-list-cell {
  232. display: flex;
  233. flex-direction: row;
  234. justify-content: space-between;
  235. align-items: center;
  236. width: 100%;
  237. }
  238. .tui-list-cell-hover {
  239. background-color: #eee !important;
  240. }
  241. .tui-list-cell-navigate {
  242. width: 100%;
  243. position: relative;
  244. padding: 30rpx 0 30rpx 30rpx;
  245. font-size: 28rpx;
  246. color: #333;
  247. }
  248. .tui-list-cell-navigate::after {
  249. content: '';
  250. position: absolute;
  251. border-bottom: 1rpx solid #eaeef1;
  252. -webkit-transform: scaleY(0.5);
  253. transform: scaleY(0.5);
  254. bottom: 0;
  255. right: 0;
  256. left: 30rpx;
  257. }
  258. .current-city {
  259. padding: 0 30rpx 30rpx;
  260. background: #fff;
  261. }
  262. .tui-icon-class {
  263. margin-right: 10rpx;
  264. }
  265. .current-city .title {
  266. font-size: 24rpx;
  267. line-height: 24rpx;
  268. color: #999;
  269. }
  270. .city-name {
  271. display: flex;
  272. align-items: center;
  273. margin-top: 17rpx;
  274. font-size: 30rpx;
  275. font-weight: bold;
  276. line-height: 30rpx;
  277. color: #333;
  278. }
  279. .hot-city .title {
  280. height: 48rpx !important;
  281. padding-left: 30rpx;
  282. font-size: 24rpx !important;
  283. line-height: 48rpx !important;
  284. color: #999;
  285. background: #f2f5f7 !important;
  286. }
  287. .city-names {
  288. display: flex;
  289. flex-wrap: wrap;
  290. justify-content: space-between;
  291. align-content: space-between;
  292. width: 630rpx;
  293. padding: 12rpx 90rpx 26rpx 30rpx;
  294. background: #fff;
  295. }
  296. .city-name-item {
  297. display: flex;
  298. justify-content: center;
  299. align-items: center;
  300. width: 140rpx;
  301. height: 56rpx;
  302. margin-top: 16rpx;
  303. /* border: solid 1rpx #ccc; */
  304. border-radius: 28rpx;
  305. font-size: 28rpx;
  306. color: #333;
  307. position: relative;
  308. }
  309. .city-name-item::before {
  310. content: "";
  311. position: absolute;
  312. width: 200%;
  313. height: 200%;
  314. -webkit-transform-origin: 0 0;
  315. transform-origin: 0 0;
  316. -webkit-transform: scale(0.5, 0.5);
  317. transform: scale(0.5, 0.5);
  318. -webkit-box-sizing: border-box;
  319. box-sizing: border-box;
  320. left: 0;
  321. top: 0;
  322. border-radius: 56rpx;
  323. border: 1px solid #ccc;
  324. }
  325. .tap-city {
  326. color: #fff;
  327. background: #5677fc;
  328. /* border: solid 1rpx #5677fc; */
  329. }
  330. .tui-list {
  331. background-color: #fff;
  332. position: relative;
  333. width: 100%;
  334. display: flex;
  335. flex-direction: column;
  336. padding-bottom: env(safe-area-inset-bottom);
  337. }
  338. .tui-list-cell-divider {
  339. height: 48rpx;
  340. padding-left: 30rpx;
  341. font-size: 24rpx;
  342. color: #999;
  343. background: #f2f5f7;
  344. padding: 0 30rpx;
  345. display: flex;
  346. align-items: center;
  347. }
  348. .tui-indexed-list-bar {
  349. display: flex;
  350. flex-direction: column;
  351. align-items: center;
  352. justify-content: flex-start;
  353. z-index: 9999;
  354. position: absolute;
  355. top: 132rpx;
  356. right: 0;
  357. padding-right: 10rpx;
  358. width: 44rpx;
  359. }
  360. .tui-indexed-list-text {
  361. font-size: 22rpx;
  362. white-space: nowrap;
  363. }
  364. .tui-indexed-list-bar.active {
  365. background-color: rgb(200, 200, 200);
  366. }
  367. .tui-indexed-list-alert {
  368. position: absolute;
  369. z-index: 20;
  370. width: 160rpx;
  371. height: 160rpx;
  372. left: 50%;
  373. top: 50%;
  374. margin-left: -80rpx;
  375. margin-top: -80rpx;
  376. border-radius: 80rpx;
  377. text-align: center;
  378. line-height: 160rpx;
  379. font-size: 70rpx;
  380. color: #fff;
  381. background-color: rgba(0, 0, 0, 0.5);
  382. }
  383. </style>