景徳镇旅游微信小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

269 lines
5.6 KiB

7 months ago
7 months ago
7 months ago
7 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
7 months ago
7 months ago
  1. <template>
  2. <!-- 达人和讲述 -->
  3. <view class="tell">
  4. <navbar :title="dict.title" leftClick @leftClick="$utils.navigateBack" />
  5. <view class="tell-top" v-if="dict.screen">
  6. <!-- <view>级别</view>
  7. <view>遗产点</view> -->
  8. <uv-drop-down ref="dropDown" sign="dropDown_1" text-active-color="#B12026"
  9. :extra-icon="{name:'arrow-down-fill',color:'#666',size:'26rpx'}"
  10. :extra-active-icon="{name:'arrow-up-fill',color:'#B12026',size:'26rpx'}"
  11. :defaultValue="defaultValue"
  12. :custom-style="{padding: '0 auto'}"
  13. @click="selectMenu">
  14. <uv-drop-down-item name="level" type="2"
  15. :label="dropItem('level').label"
  16. :value="dropItem('level').value">
  17. </uv-drop-down-item>
  18. <!-- <uv-drop-down-item name="spot" type="2"
  19. :label="dropItem('spot').label"
  20. :value="dropItem('spot').value">
  21. </uv-drop-down-item> -->
  22. <uv-drop-down-item name="spot" type="1"
  23. :label="dropItem('spot').label"
  24. :value="dropItem('spot').value">
  25. </uv-drop-down-item>
  26. </uv-drop-down>
  27. <uv-drop-down-popup
  28. sign="dropDown_1"
  29. :click-overlay-on-close="true"
  30. :currentDropItem="currentDropItem"
  31. @clickItem="clickItem"
  32. @popupChange="change"
  33. ></uv-drop-down-popup>
  34. </view>
  35. <cardList :type="type" :result="result" :dict="dict" ref="cardList" :showRoleLevel="dict.showRoleLevel" />
  36. <selectionPopup
  37. ref="selectionPopup"
  38. @select="select"/>
  39. <tabber />
  40. </view>
  41. </template>
  42. <script>
  43. import cardList from '../components/list/cardList.vue'
  44. import selectionPopup from '@/components/tourGuide/selectionPopup.vue'
  45. import { mapState } from 'vuex'
  46. export default {
  47. components: {
  48. cardList,
  49. selectionPopup,
  50. },
  51. data() {
  52. return {
  53. type: '',
  54. dict: {},
  55. // 表示value等于这些值,就属于默认值
  56. defaultValue: [0, 'all'],
  57. // 筛选结果
  58. result: [],
  59. activeName: 'level',
  60. level: {
  61. label: '级别',
  62. value: 0,
  63. activeIndex: 0,
  64. color: '#333',
  65. activeColor: '#B12026',
  66. child: [
  67. {
  68. label: '全部',
  69. value: 0,
  70. },
  71. {
  72. label: '金牌讲解员',
  73. value: 1
  74. },
  75. {
  76. label: '专业讲解员',
  77. value: 2
  78. },
  79. ]
  80. },
  81. spot: {
  82. label: '遗产点',
  83. value: 'all',
  84. activeIndex: 0,
  85. color: '#333',
  86. activeColor: '#B12026',
  87. child: [
  88. {
  89. label: '全部',
  90. value: 'all'
  91. },
  92. ]
  93. },
  94. }
  95. },
  96. computed: {
  97. dropItem(name) {
  98. return (name) => {
  99. const result = {};
  100. const find = this.result.find(item => item.name === name);
  101. if (find) {
  102. result.label = find.label;
  103. result.value = find.value;
  104. } else {
  105. result.label = this[name].label;
  106. result.value = this[name].value;
  107. }
  108. return result;
  109. }
  110. },
  111. // 获取当前下拉筛选项
  112. currentDropItem() {
  113. return this[this.activeName];
  114. },
  115. ...mapState(['spotList']),
  116. },
  117. onLoad(args) {
  118. this.type = args.type
  119. this.dict = this.$config.dict[args.type]
  120. },
  121. onShow() {
  122. this.$nextTick(() => {
  123. this.$refs.cardList.getList()
  124. })
  125. let list = this.spotList
  126. .filter(n => n.categoryId == 0)
  127. .map(n => {
  128. return {
  129. label : n.spotName,
  130. value : n.spotName
  131. }
  132. })
  133. //设置遗产点
  134. this.spot.child = [
  135. {
  136. label: '全部',
  137. value: 'all'
  138. },
  139. ...list
  140. ]
  141. },
  142. onPullDownRefresh() {
  143. this.$refs.cardList.getList()
  144. },
  145. //滚动到屏幕底部
  146. onReachBottom() {
  147. this.$refs.cardList.loadMoreList()
  148. },
  149. methods: {
  150. change(e) {
  151. },
  152. /**
  153. * 点击每个筛选项回调
  154. * @param {Object} e { name, active, type } = e
  155. */
  156. selectMenu(e) {
  157. const {
  158. name,
  159. active,
  160. type
  161. } = e;
  162. this.activeName = name;
  163. if(type == 1){
  164. this.$refs.selectionPopup.open()
  165. return
  166. }
  167. const find = this.result.find(item => item.name == this.activeName);
  168. if (find) {
  169. const findIndex = this[this.activeName]
  170. .child.findIndex(item => item.label == find.label && item
  171. .value == find.value);
  172. this[this.activeName].activeIndex = findIndex;
  173. } else {
  174. this[this.activeName].activeIndex = 0;
  175. }
  176. },
  177. /**
  178. * 点击菜单回调处理
  179. * @param {Object} item 选中项 { label,value } = e
  180. */
  181. clickItem(e) {
  182. // 下面有重新赋值,所以用let
  183. let {
  184. label,
  185. value
  186. } = e;
  187. const findIndex = this.result.findIndex(item => item.name == this.activeName);
  188. if (this.defaultValue.indexOf(value) > -1 && this[this.activeName].label) {
  189. label = this[this.activeName].label;
  190. }
  191. // 已经存在筛选项
  192. if (findIndex > -1) {
  193. this.$set(this.result, findIndex, {
  194. name: this.activeName,
  195. label,
  196. value
  197. })
  198. } else {
  199. this.result.push({
  200. name: this.activeName,
  201. label,
  202. value
  203. });
  204. }
  205. this.result = this.result.filter(item => this.defaultValue.indexOf(item.value) == -1);
  206. // uni.showModal({
  207. // content: `筛选的值:${JSON.stringify(this.result)}`
  208. // })
  209. this.$nextTick(() => {
  210. this.$refs.cardList.getList()
  211. })
  212. },
  213. select(n){
  214. this.clickItem({
  215. label : n.spotName,
  216. value : n.spotName
  217. })
  218. },
  219. }
  220. }
  221. </script>
  222. <style scoped lang="scss">
  223. .tell {
  224. /deep/ .uv-drop-down{
  225. justify-content: space-around;
  226. width: 750rpx;
  227. }
  228. .tell-top {
  229. display: flex;
  230. justify-content: left;
  231. align-items: center;
  232. height: 80rpx;
  233. background-color: #fff;
  234. border-top: 2rpx solid #D0D0D0;
  235. border-bottom: 2rpx solid #D0D0D0;
  236. view {
  237. flex: 1;
  238. margin-left: 5%;
  239. }
  240. }
  241. }
  242. </style>