dmHomeChoose.vue 7.7 KB

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