dmHomeChoose.vue 8.1 KB

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