店播抖音版小程序

classify.vue 7.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <template>
  2. <view class="mask" @click="closeEvent" @touchmove.stop.prevent="()=>false">
  3. <view class="content" @click.stop="closeEvent(1)" :style="'padding-bottom:'+isIpx?130:110+'rpx'">
  4. <view class="titleBox">
  5. <text></text>
  6. <text>{{choiceTitle}}</text>
  7. <image src="/static/new_close.png" mode="widthFix" class="close" @click.stop="closeEvent"></image>
  8. </view>
  9. <view class="selected">
  10. 已选:<span>{{choiceData.main.category_name + (choiceData.secondLevel.category_name ? (' > ' + choiceData.secondLevel.category_name) : '') + (choiceData.threeLevel.category_name ? (' > ' + choiceData.threeLevel.category_name) : '')}}</span>
  11. </view>
  12. <view class="container">
  13. <view class="categoryTitle" style="margin-top:0">主分类:</view>
  14. <view class="stageView">
  15. <view :class="['item',choiceData.main.category_name == item.category_name ? 'item_active' :'']" @click.stop="levelEvent(item,'secondLevel')" :style="!item.child?'justify-content:center':''" v-for="(item,index) in categoryList" :key='item.id'>
  16. <text>{{item.category_name}}</text>
  17. <i class="iconfont icon-down_icon jt" v-if="item.child"></i>
  18. <!-- <image src="../static/jt.png" mode="widthFix" class="jt" v-if="item.child"></image> -->
  19. <view v-else></view>
  20. </view>
  21. </view>
  22. <template v-if="secondLevelList.length!=0">
  23. <view class="categoryTitle wrongMainTitle">{{choiceData.main.category_name}}:</view>
  24. <view class="stageView">
  25. <view :class="['item',choiceData.secondLevel.category_name == item.category_name ? 'item_active' :'']" @click.stop="levelEvent(item,'threeLevel')" :style="!item.child?'justify-content:center':''" v-for="(item,index) in secondLevelList" :key='item.id'>
  26. <text>{{item.category_name}}</text>
  27. <i class="iconfont icon-down_icon jt" v-if="item.child"></i>
  28. <!-- <image src="../static/jt.png" mode="widthFix" class="jt" ></image> -->
  29. <view v-else></view>
  30. </view>
  31. </view>
  32. </template>
  33. <template v-if="threeLevelList.length!=0">
  34. <view class="categoryTitle wrongMainTitle">{{choiceData.secondLevel.category_name}}:</view>
  35. <view class="stageView">
  36. <view :class="['item',choiceData.threeLevel.category_name == item.category_name ? 'item_active' :'']" @click.stop="levelEvent(item,'lastLevel')" :style="!item.child?'justify-content:center':''" v-for="(item,index) in threeLevelList" :key='item.id'>
  37. <text>{{item.category_name}}</text>
  38. <i class="iconfont icon-down_icon jt" v-if="item.child"></i>
  39. <!-- <image src="../static/jt.png" mode="widthFix" class="jt" v-if="item.child"></image> -->
  40. <view v-else></view>
  41. </view>
  42. </view>
  43. </template>
  44. <button class="selfButton" :hover-stop-propagation='true' @click.stop="submitEvent">确定</button>
  45. </view>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. export default {
  51. name: "classify",
  52. props: {
  53. choiceTitle: {
  54. type: String,
  55. default: '账号分类筛选'
  56. }
  57. },
  58. data() {
  59. return {
  60. isIpx: this.$store.state.systemInfo.isIpx,
  61. categoryList:[],
  62. secondLevelList:[],
  63. threeLevelList:[],
  64. choiceData:{
  65. main:{},
  66. secondLevel:{},
  67. threeLevel:{}
  68. }
  69. };
  70. },
  71. created() {
  72. if(this.$store.state.brandCategoryList&&this.$store.state.brandCategoryList.length!=0){
  73. this.categoryList = this.$store.state.brandCategoryList;
  74. this.choiceData.main = this.categoryList[0];
  75. }else{
  76. this.getCategory()
  77. }
  78. },
  79. methods: {
  80. submitEvent(){
  81. this.$emit('getData',this.choiceData)
  82. this.$emit('close')
  83. },
  84. closeEvent(type) {
  85. if (type == 1) {
  86. return
  87. }
  88. this.$emit('close')
  89. },
  90. levelEvent(data,type){
  91. if(type=='lastLevel'){
  92. this.choiceData.threeLevel = {
  93. category_name:data.category_name,
  94. id:data.id
  95. }
  96. return
  97. }
  98. if(data.child){
  99. if(type=='secondLevel'){
  100. this.choiceData.main = {
  101. category_name:data.category_name,
  102. id:data.id
  103. }
  104. this.choiceData.threeLevel = {};
  105. this.choiceData.secondLevel = {};
  106. if(data.child){
  107. this.secondLevelList = data.child
  108. this.threeLevelList = []
  109. }
  110. }
  111. if(type=='threeLevel'){
  112. this.choiceData.secondLevel = {
  113. category_name:data.category_name,
  114. id:data.id
  115. }
  116. this.choiceData.threeLevel = {};
  117. if(data.child){
  118. this.threeLevelList = data.child
  119. }
  120. }
  121. }else{
  122. if(type=='secondLevel'){
  123. this.choiceData.main = {
  124. category_name:data.category_name,
  125. id:data.id
  126. }
  127. this.choiceData.threeLevel = {};
  128. this.choiceData.secondLevel = {};
  129. this.secondLevelList = []
  130. this.threeLevelList = [];
  131. }
  132. if(type == 'threeLevel'){
  133. this.choiceData.threeLevel = {};
  134. this.choiceData.secondLevel = {
  135. category_name:data.category_name,
  136. id:data.id
  137. }
  138. this.threeLevelList = []
  139. }
  140. }
  141. },
  142. getCategory(){
  143. this.$req(this.$api.category_list,'get',{},(res)=>{
  144. if(res && res.errno == 0){
  145. this.categoryList = [{category_name:'不限',id:''}]
  146. this.categoryList = this.categoryList.concat(res.rst);
  147. this.choiceData.main = this.categoryList[0]
  148. this.$store.state.brandCategoryList = this.categoryList;
  149. }else{
  150. }
  151. })
  152. }
  153. }
  154. }
  155. </script>
  156. <style scoped lang="scss">
  157. .mask {
  158. width: 100%;
  159. height: 100vh;
  160. background-color: rgba(0, 0, 0, 0.5);
  161. position: fixed;
  162. top: 0;
  163. left: 0;
  164. z-index: 999;
  165. }
  166. .mask .content {
  167. width: 100%;
  168. min-height: 300rpx;
  169. background-color: #ffffff;
  170. border-radius: 40rpx 40rpx 0 0;
  171. position: absolute;
  172. bottom: 0;
  173. left: 0;
  174. padding: 10rpx 30rpx 160rpx;
  175. }
  176. .titleBox {
  177. width: 100%;
  178. display: flex;
  179. align-items: center;
  180. justify-content: space-between;
  181. margin-bottom: 30rpx;
  182. color: #000000;
  183. }
  184. .titleBox text {
  185. font-size: 30rpx;
  186. }
  187. .close {
  188. width: 30rpx;
  189. height: 30rpx;
  190. padding: 30rpx;
  191. padding-right: 0;
  192. }
  193. .container{
  194. max-height: 60vh;
  195. min-height: 800rpx;
  196. overflow-y: auto;
  197. }
  198. .selected{
  199. font-size: 24rpx;
  200. color: #666;
  201. padding-bottom: 20rpx;
  202. span{
  203. color: #fe9400;
  204. background: #fff3e3;
  205. display: inline-block;
  206. padding: 2px 4px;
  207. border-radius: 4px;
  208. }
  209. }
  210. .stageView{
  211. display: flex;
  212. flex-wrap: wrap;
  213. margin: 20rpx 0;
  214. .item{
  215. display: flex;
  216. align-items: center;
  217. justify-content: center;
  218. width: 23%;
  219. background: #f4f4f4;
  220. border-radius: 50rpx;
  221. padding: 10rpx 0rpx;
  222. margin: 10rpx 0;
  223. margin-right: 2.3%;
  224. &:nth-of-type(4n){
  225. margin-right: 0;
  226. }
  227. text{
  228. color: #333;
  229. font-size: 24rpx;
  230. }
  231. .jt{
  232. color: #616161;
  233. font-size: 20rpx;
  234. transform: scale(0.6);
  235. }
  236. }
  237. .item_active{
  238. background: #fff3e3;
  239. text{
  240. color: #fe9400;
  241. }
  242. .itemIcon{
  243. border-color: #fe9400;
  244. }
  245. .jt{
  246. color: #fe9400;
  247. }
  248. }
  249. }
  250. .categoryTitle{
  251. font-size: 28rpx;
  252. line-height: 40rpx;
  253. margin-top: 20rpx;
  254. color: #333333;
  255. }
  256. .wrongMainTitle{
  257. border-top: 1px solid #f9f9f9;
  258. padding-top: 30rpx;
  259. }
  260. .selfButton{
  261. background: #fe9400;
  262. color: #FFFFFF;
  263. border: none;
  264. font-size: 30rpx;
  265. line-height: 80rpx;
  266. width: 80%;
  267. border-radius: 80rpx;
  268. margin-top:40rpx;
  269. }
  270. </style>