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