dmPickerView_options.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. <template>
  2. <dm-pop-view ref='popView' :isShowConfirm="false" :title="title" :maskTapHide='maskTapHide' :isScannerOption="true" @close="onClose">
  3. <view class="content_options">
  4. <div class="options_title">
  5. <text>时间</text>
  6. <text class="options_time" v-if="beginDate">
  7. <text>{{beginDate | visitTimeFilter}}</text>
  8. <text v-if="endDate">-</text>
  9. <text v-if="endDate">{{endDate | visitTimeFilter}}</text>
  10. </text>
  11. </div>
  12. <view class="list-items">
  13. <text v-for="(item,index) in timeOptions" class="itemB" :style="{background: (currentTime==index)? themeColor:'#F1F5F9',color: (currentTime==index)? '#ffffff':'#333333'}"
  14. @click="selectTime(item,index)">{{item.name}}</text>
  15. </view>
  16. <text class="options_title">排序</text>
  17. <view class="list-items">
  18. <text v-for="(item,index) in sortTypes" class="itemB" :style="{background: (currentSortType==index)? themeColor:'#F1F5F9',color: (currentSortType==index)? '#ffffff':'#333333'}"
  19. @click="selectsortTypeAction(item,index)">{{item.name}}</text>
  20. </view>
  21. <text class="options_title">活动列表</text>
  22. <view class="list-items">
  23. <text v-for="(item,index) in huodongList" class="itemA" :style="{background: (currentHuodong==index)? themeColor:'#F1F5F9',color: (currentHuodong==index)? '#ffffff':'#333333'}"
  24. @click="selectHuodong(item,index)">{{item.titleActivity}}</text>
  25. </view>
  26. <view class="bottomBtn">
  27. <view class="resetBtn" :style="`background-color: ${themeColor25};`" @click="resetAction">重置</view>
  28. <view class="sureBtn" :style="`background-color: ${themeColor};`" @click="handleConfirm">确定</view>
  29. </view>
  30. </view>
  31. <dm-calendar-picker-view ref='calendarPickerView' @confirmSelDate='confirmSelDate'></dm-calendar-picker-view>
  32. </dm-pop-view>
  33. </template>
  34. <script>
  35. import dmPopView from './dmPopView.vue'
  36. import dmCalendarPickerView from './dmCalendarPickerView.vue'
  37. import {
  38. displayDateFormat
  39. } from '../../static/format.js'
  40. export default {
  41. props: {
  42. huodongList: {
  43. type: Array,
  44. default: () => {
  45. return []
  46. }
  47. },
  48. title: {
  49. type: String,
  50. default: '请选择'
  51. },
  52. maskTapHide: {
  53. type: Boolean,
  54. default: true
  55. },
  56. },
  57. data() {
  58. return {
  59. themeColor: "",
  60. fuzhuClolor: "",
  61. themeColor25: "",
  62. themeColor50: "",
  63. currentHuodong: -1,
  64. selectedItem: null,
  65. timeOptions: [{
  66. name: "今天",
  67. value: "1"
  68. },
  69. {
  70. name: "近一周",
  71. value: "2"
  72. },
  73. {
  74. name: "近一月",
  75. value: "3"
  76. },
  77. {
  78. name: "自定义",
  79. value: "4"
  80. }
  81. ],
  82. sortTypes: [{
  83. name: "按获券时间倒序",
  84. value: "1"
  85. },
  86. {
  87. name: "按获券时间正序",
  88. value: "2"
  89. },
  90. {
  91. name: "按核销时间倒序",
  92. value: "3"
  93. },
  94. {
  95. name: "按核销时间正序",
  96. value: "4"
  97. }
  98. ],
  99. currentTime: -1,
  100. selectedTime: "",
  101. currentSortType: -1,
  102. selectedSortType: "",
  103. beginDate: '',
  104. endDate: ''
  105. }
  106. },
  107. mounted() {
  108. let app = getApp();
  109. this.themeColor = app.globalData.themeColor;
  110. this.fuzhuClolor = app.globalData.fuzhuColor;
  111. this.themeColor25 = app.globalData.themeColor25;
  112. this.themeColor50 = app.globalData.themeColor50;
  113. },
  114. methods: {
  115. onClose(){
  116. this.$emit("close")
  117. },
  118. show() {
  119. this.$refs.popView.show()
  120. },
  121. handleConfirm() {
  122. this.$emit('confirm', {
  123. "id": this.selectedItem && this.selectedItem.id || '',
  124. "timeRange": this.selectedTime,
  125. "sortType": this.selectedSortType,
  126. "startTime": this.selectedTime == 4 ? this.beginDate : '',
  127. "endTime": this.selectedTime == 4 ? this.endDate : ''
  128. })
  129. this.$refs.popView.hide();
  130. this.$emit("close")
  131. },
  132. resetAction() {
  133. this.currentHuodong = -1
  134. this.selectedItem = null
  135. this.currentTime = -1
  136. this.selectedTime = ''
  137. this.currentSortType = -1
  138. this.selectedSortType = ''
  139. this.beginDate = null
  140. this.endDate = null
  141. this.$forceUpdate()
  142. },
  143. selectHuodong(item, index) {
  144. this.currentHuodong = index
  145. this.selectedItem = item
  146. },
  147. selectTime(item, index) {
  148. this.currentTime = index
  149. this.selectedTime = item.value
  150. if (index == 3) {
  151. this.$refs.calendarPickerView.show()
  152. }
  153. else {
  154. this.displayDate(index)
  155. }
  156. },
  157. selectsortTypeAction(item, index) {
  158. this.currentSortType = index
  159. this.selectedSortType = item.value
  160. },
  161. confirmSelDate(e) {
  162. this.beginDate = e.startDate
  163. this.endDate = e.endDate
  164. },
  165. displayDate(dateType) {
  166. let curDate = (new Date()).getTime();
  167. this.beginDate = null
  168. this.endDate = null
  169. if (dateType == 0) {
  170. this.beginDate = curDate
  171. } else if (dateType == 1) {
  172. this.endDate = curDate
  173. this.beginDate = this.getBeginDate(6)
  174. } else if (dateType == 2) {
  175. this.endDate = curDate
  176. this.beginDate = this.getBeginDate(29)
  177. }
  178. else if (dateType == 3) {
  179. this.beginDate = this.stringToStamp(this.defaultParameter.startDate)
  180. this.endDate = this.stringToStamp(this.defaultParameter.endDate)
  181. }
  182. },
  183. getBeginDate(days) {
  184. let curDate = (new Date()).getTime();
  185. let beginDay = curDate - days * 24 * 60 * 60 * 1000
  186. return beginDay
  187. },
  188. stringToStamp(val) {
  189. var timeStr = val.replace('-', '/') + ' ' + '00:00:00'
  190. var stamp = new Date(timeStr).getTime()
  191. return stamp
  192. }
  193. },
  194. components: {
  195. dmPopView,
  196. dmCalendarPickerView
  197. },
  198. filters: {
  199. visitTimeFilter(val) {
  200. return displayDateFormat(val)
  201. },
  202. }
  203. }
  204. </script>
  205. <style scoped lang="scss">
  206. .content_options {
  207. width: 100%;
  208. // display: flex;
  209. height: 800rpx;
  210. margin-bottom: 180rpx;
  211. // flex-direction: column;
  212. overflow-y: scroll;
  213. overflow-x: hidden;
  214. position: relative;
  215. .options_title {
  216. font-size: 32rpx;
  217. font-family: Verdana, Verdana-Bold;
  218. font-weight: 700;
  219. text-align: left;
  220. color: #454545;
  221. margin-left: 30rpx;
  222. margin-right: 15px;
  223. margin-top: 54rpx;
  224. margin-bottom: 20rpx;
  225. display: flex;
  226. flex-direction: row;
  227. justify-content: space-between;
  228. .options_time {
  229. color: #666666;
  230. font-size: 24rpx;
  231. font-family: Verdana;
  232. font-weight: 400;
  233. }
  234. }
  235. .huodong {
  236. width: 146rpx;
  237. height: 56rpx;
  238. border-radius: 8rpx;
  239. }
  240. .list-items {
  241. // margin-top: 20rpx;
  242. width: 100%;
  243. display: flex;
  244. flex-direction: row;
  245. justify-content: flex-start;
  246. flex-wrap: wrap;
  247. // margin-bottom: 40rpx;
  248. padding-left: 24rpx;
  249. padding-right: 4rpx;
  250. .item {
  251. border-radius: 12rpx;
  252. width: 220rpx;
  253. height: 72rpx;
  254. text-align: center;
  255. margin-right: 20rpx;
  256. margin-bottom: 20rpx;
  257. line-height: 72rpx;
  258. font-size: 28rpx;
  259. overflow: hidden;
  260. text-overflow: ellipsis;
  261. white-space: nowrap;
  262. }
  263. .itemA {
  264. border-radius: 12rpx;
  265. width: 700rpx;
  266. height: 72rpx;
  267. padding-left: 20rpx;
  268. box-sizing: border-box;
  269. text-align: left;
  270. margin-right: 20rpx;
  271. margin-bottom: 20rpx;
  272. line-height: 72rpx;
  273. font-size: 28rpx;
  274. overflow: hidden;
  275. text-overflow: ellipsis;
  276. white-space: nowrap;
  277. }
  278. .itemB {
  279. border-radius: 12rpx;
  280. width: 340rpx;
  281. height: 72rpx;
  282. padding-left: 20rpx;
  283. box-sizing: border-box;
  284. text-align: center;
  285. margin-right: 20rpx;
  286. margin-bottom: 20rpx;
  287. line-height: 72rpx;
  288. font-size: 28rpx;
  289. overflow: hidden;
  290. text-overflow: ellipsis;
  291. white-space: nowrap;
  292. }
  293. }
  294. .bottomBtn {
  295. position: fixed;
  296. bottom: 0;
  297. left: 0;
  298. height: 180rpx;
  299. width: 100%;
  300. // background-color: rgba($color: #000000, $alpha: 0.1);
  301. background-color: #FFFFFF;
  302. display: flex;
  303. flex-direction: row;
  304. justify-content: space-between;
  305. font-size: 28rpx;
  306. font-family: Verdana;
  307. text-align: center;
  308. padding: 40rpx 60rpx 60rpx 60rpx;
  309. box-sizing: border-box;
  310. .resetBtn {
  311. width: 156rpx;
  312. height: 80rpx;
  313. color: #666666;
  314. line-height: 80rpx;
  315. border-radius: 40rpx;
  316. }
  317. .sureBtn {
  318. width: 444rpx;
  319. height: 80rpx;
  320. color: #fff;
  321. line-height: 80rpx;
  322. border-radius: 40rpx;
  323. }
  324. }
  325. }
  326. </style>