dmHomeChoose.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. <template>
  2. <view class="pop-view" v-if='visible'>
  3. <view class="pop-maskView" :style="{
  4. 'background-color': maskBgColor,
  5. zIndex: zIndex - 1
  6. }" @tap.stop="handleMaskTap"
  7. @touchmove.stop.prevent="moveHandle">
  8. </view>
  9. <view :class="['pop-contentView',containerVisible ? 'pop-contentView-show' : '']" :style="{zIndex: zIndex}"
  10. @touchmove.stop.prevent="moveHandle">
  11. <view class="content">
  12. <view class="content_top">
  13. <view class="content_left">
  14. <view class="content_item" @click="type(1)" :style="{background:tab==1?'#f8f8f8':'transparent'}">
  15. 城市
  16. </view>
  17. <view class="content_item" @click="type(2)" :style="{background:tab==2?'#f8f8f8':'transparent'}">
  18. 类型
  19. </view>
  20. </view>
  21. <view class="content_right">
  22. <view class="content_city" v-if="tab==1">
  23. <scroll-view scroll-y="true" class="city_province">
  24. <view class="province_item" v-for="(item1,index1) in region" :key='index1.id' @click="chooceProvince(item1)" :style="{'color':provinceId==item1.id?color1:'#999999','background':provinceId==item1.id?'#FFFFFF':'transparent'}">
  25. {{item1.name}}
  26. </view>
  27. </scroll-view>
  28. <scroll-view scroll-y="true" class="city_town">
  29. <view class="city_item" v-for="(item2,index2) in cities" :key='item2.id' @click="chooseCity(item2)" :style="{'color':cityId==item2.id?color1:'#999999'}">
  30. {{item2.name}}
  31. </view>
  32. </scroll-view>
  33. </view>
  34. <view class="content_type" v-if="tab==2">
  35. <view class="content_type_item" v-for="(item,index) in types" :key='item.id' @click="typeChooce(item)" :style='{color:currentType==item.id?color1:"#999999"}'>
  36. {{item.name}}
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="bottom">
  42. <view class="reset" @click="reset">
  43. 重置
  44. </view>
  45. <view class="confirm" @click="confirm">
  46. 确定
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. let region = require('@/static/region.json');
  55. export default {
  56. props: {
  57. title: String,
  58. maskColor: {
  59. type: String,
  60. default: 'rgba(0, 0, 0, 0.3)'
  61. },
  62. zIndex: {
  63. type: Number,
  64. default: 999
  65. },
  66. maskTapHide: {
  67. type: Boolean,
  68. default: true
  69. },
  70. isShowTitle: {
  71. type: Boolean,
  72. default: true
  73. },
  74. isShowClose: {
  75. type: Boolean,
  76. default: true
  77. },
  78. isShowConfirm: {
  79. type: Boolean,
  80. default: true
  81. },
  82. isScannerOption:{
  83. type:Boolean,
  84. default:false
  85. },
  86. marginSize:{
  87. type: String,
  88. default: '20rpx'
  89. },
  90. },
  91. data() {
  92. return {
  93. visible: false,
  94. containerVisible: false,
  95. maskBgColor: '',
  96. selectValue: [0],
  97. selIdx: 0,
  98. color2:'',
  99. color1:'',
  100. tab:1,
  101. types:[],
  102. currentType:"",
  103. region:[],
  104. cities:[],
  105. province:"",
  106. provinceId:"",
  107. city:"",
  108. cityId:"",
  109. typeName:"",
  110. }
  111. },
  112. mounted() {
  113. let app = getApp();
  114. this.globalData = app.globalData;
  115. this.color2 = this.globalData.color2;
  116. this.color1 = this.globalData.color1;
  117. this.region = region;
  118. this.cities = region[0].children;
  119. },
  120. methods: {
  121. async queryCategoryBox(){
  122. let res = await this.$myRequest({
  123. url: "/task/queryCategoryBox",
  124. data: {
  125. whetherBox: false
  126. }
  127. })
  128. if(res.data.success){
  129. this.types = res.data.list||[];
  130. }
  131. },
  132. setOptionType(option){
  133. this.tab = option;
  134. },
  135. show() {
  136. this.visible = true
  137. setTimeout(() => {
  138. this.maskBgColor = this.maskColor
  139. this.containerVisible = true
  140. }, 20)
  141. console.log("regin",region)
  142. this.queryCategoryBox();
  143. },
  144. hide() {
  145. this.maskBgColor = ''
  146. this.containerVisible = false
  147. this.visible = false
  148. this.$emit('close')
  149. },
  150. handleCancel() {
  151. this.hide()
  152. },
  153. handleConfirm() {
  154. this.hide()
  155. this.$emit('confirm')
  156. },
  157. handleMaskTap() {
  158. if (this.maskTapHide) {
  159. this.hide()
  160. }
  161. },
  162. moveHandle() {},
  163. type(tab){
  164. this.tab = tab;
  165. },
  166. typeChooce(item){
  167. this.currentType = item.id;
  168. this.typeName = item.name;
  169. },
  170. chooceProvince(item){
  171. this.cities = item.children;
  172. this.province = item.name;
  173. this.provinceId = item.id;
  174. },
  175. chooseCity(item){
  176. this.city = item.name;
  177. this.cityId = item.id;
  178. },
  179. reset(){
  180. this.city = "";
  181. this.cityId = "";
  182. this.province = "";
  183. this.provinceId = "";
  184. this.currentType = "";
  185. this.typeName = "";
  186. },
  187. confirm(){
  188. let param = {
  189. type:this.currentType,
  190. typeName:this.typeName,
  191. city:this.city,
  192. }
  193. this.$emit('chooiceType',param)
  194. this.handleConfirm()
  195. }
  196. }
  197. }
  198. </script>
  199. <style scoped lang="scss">
  200. .pop-view {
  201. position: relative;
  202. .pop-maskView {
  203. position: fixed;
  204. top: 0;
  205. right: 0;
  206. left: 0;
  207. bottom: 0;
  208. }
  209. .pop-contentView {
  210. position: fixed;
  211. left: 0;
  212. right: 0;
  213. top: 0;
  214. overflow-y: scroll;
  215. background-color: #fff;
  216. display: flex;
  217. flex-direction: column;
  218. align-items: center;
  219. .pop-title {
  220. margin-top: 60rpx;
  221. font-size: 32rpx;
  222. font-family: Verdana, Verdana-Bold;
  223. font-weight: 700;
  224. text-align: center;
  225. color: #333333;
  226. }
  227. .pop-close {
  228. position: absolute;
  229. top: 64rpx;
  230. right: 30rpx;
  231. width: 40rpx;
  232. height: 40rpx;
  233. }
  234. .pop-commit {
  235. margin-bottom: 54rpx;
  236. width: 260rpx;
  237. height: 84rpx;
  238. line-height: 84rpx;
  239. border-radius: 42rpx;
  240. font-size: 32rpx;
  241. font-family: Verdana, Verdana-Regular;
  242. font-weight: 400;
  243. text-align: center;
  244. color: #ffffff;
  245. }
  246. }
  247. .pop-contentView-show {
  248. }
  249. .content{
  250. width: 100%;
  251. .content_top{
  252. width: 100%;
  253. height: 470rpx;
  254. display: flex;
  255. .content_left{
  256. width: 140rpx;
  257. height: 470rpx;
  258. background: #f0f1f2;
  259. padding-top: 50rpx;
  260. box-sizing: border-box;
  261. display: flex;
  262. flex-direction: column;
  263. align-items: center;
  264. .content_item{
  265. width: 140rpx;
  266. height: 60rpx;
  267. line-height: 60rpx;
  268. text-align: center;
  269. font-size: 28rpx;
  270. font-family: Verdana, Verdana-Regular;
  271. font-weight: 400;
  272. color: #666666;
  273. margin-bottom: 20rpx;
  274. }
  275. }
  276. .content_right{
  277. box-sizing: border-box;
  278. height: 100%;
  279. .content_city{
  280. display: flex;
  281. height: 100%;
  282. box-sizing: border-box;
  283. .city_province{
  284. width: 280rpx;
  285. min-width: 280rpx;
  286. height: 100%;
  287. box-sizing: border-box;
  288. padding-top: 50rpx;
  289. background: #f8f8f8;
  290. overflow: hidden;
  291. overflow-y: scroll;
  292. .province_item{
  293. width: 280rpx;
  294. line-height: 60rpx;
  295. text-align: center;
  296. font-size: 28rpx;
  297. font-family: Verdana, Verdana-Regular;
  298. font-weight: 400;
  299. color: #999999;
  300. }
  301. }
  302. .city_town{
  303. overflow-y: scroll;
  304. padding-top: 50rpx;
  305. box-sizing: border-box;
  306. .city_item{
  307. width: 300rpx;
  308. line-height: 60rpx;
  309. font-size: 28rpx;
  310. font-family: Verdana, Verdana-Regular;
  311. font-weight: 400;
  312. text-align: center;
  313. color: #999999;
  314. }
  315. }
  316. }
  317. .content_type{
  318. padding-top: 40rpx;
  319. padding-left: 60rpx;
  320. box-sizing: border-box;
  321. .content_type_item{
  322. line-height: 75rpx;
  323. text-align: center;
  324. font-size: 28rpx;
  325. font-family: Verdana, Verdana-Regular;
  326. font-weight: 400;
  327. color: #999999;
  328. }
  329. }
  330. }
  331. }
  332. .bottom{
  333. width: 100%;
  334. height: 140rpx;
  335. background: #ffffff;
  336. display: flex;
  337. justify-content: center;
  338. align-items: center;
  339. .reset{
  340. width: 156rpx;
  341. height: 80rpx;
  342. line-height: 80rpx;
  343. background: #f8f8f8;
  344. border-radius: 40rpx;
  345. font-size: 28rpx;
  346. font-family: Verdana, Verdana-Bold;
  347. font-weight: 700;
  348. text-align: center;
  349. color: #f07423;
  350. }
  351. .confirm{
  352. width: 444rpx;
  353. height: 80rpx;
  354. line-height: 80rpx;
  355. background: #f07423;
  356. border-radius: 40rpx;
  357. font-size: 28rpx;
  358. font-family: Verdana, Verdana-Bold;
  359. font-weight: 700;
  360. text-align: center;
  361. color: #ffffff;
  362. margin-left: 30rpx;
  363. }
  364. }
  365. }
  366. }
  367. </style>