dmHomeChoose.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  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. this.types = this.types.filter(item=>item.name.indexOf('注册')==-1)
  131. }
  132. },
  133. setOptionType(option){
  134. this.tab = option;
  135. },
  136. show() {
  137. this.visible = true
  138. setTimeout(() => {
  139. this.maskBgColor = this.maskColor
  140. this.containerVisible = true
  141. }, 20)
  142. console.log("regin",region)
  143. this.queryCategoryBox();
  144. },
  145. hide() {
  146. this.maskBgColor = ''
  147. this.containerVisible = false
  148. this.visible = false
  149. this.$emit('close')
  150. },
  151. handleCancel() {
  152. this.hide()
  153. },
  154. handleConfirm() {
  155. this.hide()
  156. this.$emit('confirm')
  157. },
  158. handleMaskTap() {
  159. if (this.maskTapHide) {
  160. this.hide()
  161. }
  162. },
  163. moveHandle() {},
  164. type(tab){
  165. this.tab = tab;
  166. },
  167. typeChooce(item){
  168. this.currentType = item.id;
  169. this.typeName = item.name;
  170. },
  171. chooceProvince(item){
  172. this.cities = item.children;
  173. this.province = item.name;
  174. this.provinceId = item.id;
  175. },
  176. chooseCity(item){
  177. this.city = item.name;
  178. this.cityId = item.id;
  179. },
  180. reset(){
  181. this.city = "";
  182. this.cityId = "";
  183. this.province = "";
  184. this.provinceId = "";
  185. this.currentType = "";
  186. this.typeName = "";
  187. },
  188. confirm(){
  189. let param = {
  190. type:this.currentType,
  191. typeName:this.typeName,
  192. city:this.city,
  193. }
  194. this.$emit('chooiceType',param)
  195. this.handleConfirm()
  196. }
  197. }
  198. }
  199. </script>
  200. <style scoped lang="scss">
  201. .pop-view {
  202. position: relative;
  203. .pop-maskView {
  204. position: fixed;
  205. top: 0;
  206. right: 0;
  207. left: 0;
  208. bottom: 0;
  209. }
  210. .pop-contentView {
  211. position: fixed;
  212. left: 0;
  213. right: 0;
  214. top: 0;
  215. overflow-y: scroll;
  216. background-color: #fff;
  217. display: flex;
  218. flex-direction: column;
  219. align-items: center;
  220. .pop-title {
  221. margin-top: 60rpx;
  222. font-size: 32rpx;
  223. font-family: Verdana, Verdana-Bold;
  224. font-weight: 700;
  225. text-align: center;
  226. color: #333333;
  227. }
  228. .pop-close {
  229. position: absolute;
  230. top: 64rpx;
  231. right: 30rpx;
  232. width: 40rpx;
  233. height: 40rpx;
  234. }
  235. .pop-commit {
  236. margin-bottom: 54rpx;
  237. width: 260rpx;
  238. height: 84rpx;
  239. line-height: 84rpx;
  240. border-radius: 42rpx;
  241. font-size: 32rpx;
  242. font-family: Verdana, Verdana-Regular;
  243. font-weight: 400;
  244. text-align: center;
  245. color: #ffffff;
  246. }
  247. }
  248. .pop-contentView-show {
  249. }
  250. .content{
  251. width: 100%;
  252. .content_top{
  253. width: 100%;
  254. height: 470rpx;
  255. display: flex;
  256. .content_left{
  257. width: 140rpx;
  258. height: 470rpx;
  259. background: #f0f1f2;
  260. padding-top: 50rpx;
  261. box-sizing: border-box;
  262. display: flex;
  263. flex-direction: column;
  264. align-items: center;
  265. .content_item{
  266. width: 140rpx;
  267. height: 60rpx;
  268. line-height: 60rpx;
  269. text-align: center;
  270. font-size: 28rpx;
  271. font-family: Verdana, Verdana-Regular;
  272. font-weight: 400;
  273. color: #666666;
  274. margin-bottom: 20rpx;
  275. }
  276. }
  277. .content_right{
  278. box-sizing: border-box;
  279. height: 100%;
  280. .content_city{
  281. display: flex;
  282. height: 100%;
  283. box-sizing: border-box;
  284. .city_province{
  285. width: 280rpx;
  286. min-width: 280rpx;
  287. height: 100%;
  288. box-sizing: border-box;
  289. padding-top: 50rpx;
  290. background: #f8f8f8;
  291. overflow: hidden;
  292. overflow-y: scroll;
  293. .province_item{
  294. width: 280rpx;
  295. line-height: 60rpx;
  296. text-align: center;
  297. font-size: 28rpx;
  298. font-family: Verdana, Verdana-Regular;
  299. font-weight: 400;
  300. color: #999999;
  301. }
  302. }
  303. .city_town{
  304. overflow-y: scroll;
  305. padding-top: 50rpx;
  306. box-sizing: border-box;
  307. .city_item{
  308. width: 300rpx;
  309. line-height: 60rpx;
  310. font-size: 28rpx;
  311. font-family: Verdana, Verdana-Regular;
  312. font-weight: 400;
  313. text-align: center;
  314. color: #999999;
  315. }
  316. }
  317. }
  318. .content_type{
  319. padding-top: 40rpx;
  320. padding-left: 60rpx;
  321. box-sizing: border-box;
  322. .content_type_item{
  323. line-height: 75rpx;
  324. text-align: center;
  325. font-size: 28rpx;
  326. font-family: Verdana, Verdana-Regular;
  327. font-weight: 400;
  328. color: #999999;
  329. }
  330. }
  331. }
  332. }
  333. .bottom{
  334. width: 100%;
  335. height: 140rpx;
  336. background: #ffffff;
  337. display: flex;
  338. justify-content: center;
  339. align-items: center;
  340. .reset{
  341. width: 156rpx;
  342. height: 80rpx;
  343. line-height: 80rpx;
  344. background: #f8f8f8;
  345. border-radius: 40rpx;
  346. font-size: 28rpx;
  347. font-family: Verdana, Verdana-Bold;
  348. font-weight: 700;
  349. text-align: center;
  350. color: #f07423;
  351. }
  352. .confirm{
  353. width: 444rpx;
  354. height: 80rpx;
  355. line-height: 80rpx;
  356. background: #f07423;
  357. border-radius: 40rpx;
  358. font-size: 28rpx;
  359. font-family: Verdana, Verdana-Bold;
  360. font-weight: 700;
  361. text-align: center;
  362. color: #ffffff;
  363. margin-left: 30rpx;
  364. }
  365. }
  366. }
  367. }
  368. </style>