dmScreenView.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. <template>
  2. <view class="screen_view_dm">
  3. <view class="screen_container_view">
  4. <view v-if='!isShowPlatform && !isShowSecondScreen'></view>
  5. <view class="screen_btn_view" @click="tagAction('left')" v-if='isShowPlatform'>
  6. <text class="screen_btn_title">{{defaultParameter.terminal | getTerminalName}}</text>
  7. <image class="screen_btn_icon" src="../../static/icons/icon_drop_black@2x.png" mode=""></image>
  8. </view>
  9. <block v-if="midScreenList.length < 4">
  10. <view class="screen_btn_view" v-if="isShowSecondScreen">
  11. <view class="subScreen" @click="secondScreenAction">
  12. <text class="screen_btn_title">{{secondScreenName}}</text>
  13. <image class="screen_btn_icon" src="../../static/icons/icon_drop_black@2x.png" mode=""></image>
  14. </view>
  15. </view>
  16. <text :class="['screen_list',value==item.value?'screen_list_active':'']" v-if='midScreenList.length && !isEmty'
  17. v-for="(item, index) in midScreenList" :key="item.value" :style="{'color':value==item.value?themeColor:'#666666'}"
  18. @click="selectTab(item)">
  19. {{item.title}}
  20. </text>
  21. </block>
  22. <block v-else>
  23. <view class="screen_more" @click="showMidScreenPicker">
  24. <view class="screen_more_text">{{screenShowName}}</view>
  25. <image class="screen_more_icon" src="../../static/icons/icon_drop_black@2x.png" mode=""></image>
  26. </view>
  27. </block>
  28. <view class="screen_btn_view" @click="tagAction('right')">
  29. <text class="screen_btn_title">{{defaultParameter.dateType | getTimeName}}</text>
  30. <image class="screen_btn_icon" src="../../static/icons/icon_drop_black@2x.png" mode=""></image>
  31. </view>
  32. </view>
  33. <view class="timeDisplay" v-if="beginDate > 0">
  34. <text>{{beginDate | visitTimeFilter}}</text>
  35. <text v-if="endDate > 0">至</text>
  36. <text v-if="endDate > 0">{{endDate | visitTimeFilter}}</text>
  37. </view>
  38. <dm-picker-view ref="midScreenPicer" v-if="midScreenList.length >= 4" :options="midScreenList" @confirm="selectMidScreen"></dm-picker-view>
  39. </view>
  40. </template>
  41. <script>
  42. import dmPickerView from './dmPickerView.vue'
  43. import moment from '../../static/moment.min.js'
  44. import {
  45. displayDateFormat
  46. } from "../../static/format.js"
  47. export default {
  48. props: {
  49. midScreenList: {
  50. type: Array,
  51. default () {
  52. return []
  53. }
  54. },
  55. defaultParameter: {
  56. type: Object,
  57. default () {
  58. return {
  59. 'dateType': '1',
  60. 'startDate': '',
  61. 'endDate': '',
  62. 'terminal': '0'
  63. }
  64. }
  65. },
  66. isEmty:{
  67. type:Boolean,
  68. default:false
  69. },
  70. modelValue: {
  71. type: [Number, String],
  72. default: '0'
  73. },
  74. isShowPlatform:{ // 认证记录 到访记录 不显示平台
  75. type: Boolean,
  76. default: true
  77. },
  78. isShowSecondScreen: {
  79. type: Boolean,
  80. default: false
  81. },
  82. secondScreenName: {
  83. type: String,
  84. default: '按最新成交状态'
  85. }
  86. },
  87. model: {
  88. prop: 'modelValue',
  89. event: 'change'
  90. },
  91. data() {
  92. return {
  93. themeColor: '',
  94. value: this.modelValue,
  95. beginDate: null,
  96. endDate: null,
  97. screenShowName: ''
  98. }
  99. },
  100. filters: {
  101. getTerminalName(val) {
  102. if (val == '0') {
  103. return '全部平台'
  104. } else if (val == '1') {
  105. return '微信'
  106. } else if (val == '2') {
  107. return '抖音'
  108. } else if (val == '3') {
  109. return '百度'
  110. } else if (val == '4') {
  111. return '头条'
  112. } else if (val == '5') {
  113. return '支付宝'
  114. } else if (val == '6') {
  115. return 'QQ小程序'
  116. } else if (val == '7') {
  117. return '其他'
  118. }
  119. },
  120. getTimeName(val) {
  121. if (val == '1') {
  122. return '今日'
  123. } else if (val == '2') {
  124. return '近一周'
  125. } else if (val == '3') {
  126. return '近一月'
  127. } else if (val == '4') {
  128. return '自定义'
  129. }
  130. },
  131. visitTimeFilter(val) {
  132. return displayDateFormat(val)
  133. },
  134. },
  135. mounted() {
  136. let app = getApp();
  137. this.globalData = app.globalData;
  138. this.themeColor = this.globalData.themeColor;
  139. this.displayDate()
  140. },
  141. methods: {
  142. secondScreenAction() {
  143. this.$emit('secondScreenAction')
  144. },
  145. selectTab(item) {
  146. if (this.value != item.value) {
  147. this.value = item.value
  148. }
  149. },
  150. tagAction(val) {
  151. this.$emit('tagAction', val)
  152. },
  153. showMidScreenPicker() {
  154. this.$refs.midScreenPicer.show()
  155. },
  156. selectMidScreen(e) {
  157. if (this.value != e.selItem.value) {
  158. this.value = e.selItem.value
  159. }
  160. },
  161. displayDate() {
  162. var dateType = parseInt(this.defaultParameter.dateType)
  163. let curDate = (new Date()).getTime();
  164. this.beginDate = null
  165. this.endDate = null
  166. if (dateType == 1) {
  167. this.beginDate = curDate
  168. }
  169. else if (dateType == 2) {
  170. this.endDate = curDate
  171. this.beginDate = this.getBeginDate(6)
  172. }
  173. else if (dateType == 3) {
  174. this.endDate = curDate
  175. this.beginDate = this.getBeginDate(29)
  176. }
  177. else if (dateType == 4) {
  178. // var self = this
  179. // uni.showModal({
  180. // content: JSON.stringify(self.defaultParameter)
  181. // })
  182. this.beginDate = this.stringToStamp(this.defaultParameter.startDate)
  183. this.endDate = this.stringToStamp(this.defaultParameter.endDate)
  184. }
  185. },
  186. getBeginDate(days) {
  187. let curDate = (new Date()).getTime();
  188. let beginDay = curDate - days * 24 * 60 * 60 * 1000
  189. return beginDay
  190. },
  191. stringToStamp(val) {
  192. // var timeStr = val.replace('-', '/') + ' ' + '00:00:00'
  193. // var timeStr = val.replace(new RegExp("/", "gm"), "") + ' ' + '00:00:00'
  194. var timeStr = val.replace(/-/g,'/') + " " + '00:00:00'
  195. var self = this
  196. var stamp = new Date(timeStr).getTime()
  197. // debugger
  198. // uni.showModal({
  199. // content: JSON.stringify(stamp)
  200. // })
  201. return stamp
  202. }
  203. },
  204. components: {
  205. dmPickerView
  206. },
  207. watch: {
  208. //监听值变化,再赋值给modelValue
  209. value(val) {
  210. var self = this
  211. this.midScreenList.forEach((item, idx) => {
  212. if (item.value == val) {
  213. self.screenShowName = item.title
  214. }
  215. })
  216. this.$emit('change', val);
  217. },
  218. defaultParameter: {
  219. handler(e) {
  220. this.displayDate()
  221. },
  222. deep: true
  223. },
  224. modelValue: {
  225. handler(e) {
  226. this.value = e
  227. },
  228. immediate: true
  229. },
  230. midScreenList: {
  231. handler(e) {
  232. var self = this
  233. this.midScreenList.forEach((item, idx) => {
  234. if (item.value == self.value) {
  235. self.screenShowName = item.title
  236. }
  237. })
  238. },
  239. deep: true,
  240. immediate: true
  241. }
  242. }
  243. }
  244. </script>
  245. <style scoped lang="scss">
  246. .screen_view_dm {
  247. width: 750rpx;
  248. padding-top: 40rpx;
  249. padding-bottom: 10rpx;
  250. background-color: #ffffff;
  251. // z-index: 10;
  252. // position: relative;
  253. .screen_container_view {
  254. display: flex;
  255. width: 750rpx;
  256. padding: 0 20rpx;
  257. height: 40rpx;
  258. box-sizing: border-box;
  259. flex-direction: row;
  260. justify-content: space-between;
  261. align-items: center;
  262. font-family: Verdana, Verdana-Bold;
  263. .screen_btn_view {
  264. display: flex;
  265. .subScreen {
  266. display: flex;
  267. align-items: center;
  268. }
  269. .screen_btn_title {
  270. font-weight: 700;
  271. font-size: 24rpx;
  272. color: #333333;
  273. }
  274. .screen_btn_icon {
  275. width: 30rpx;
  276. height: 30rpx;
  277. }
  278. }
  279. .screen_list {
  280. font-size: 28rpx;
  281. font-weight: 400;
  282. }
  283. .screen_list_active {
  284. font-size: 28rpx;
  285. font-weight: 700;
  286. }
  287. .screen_more {
  288. display: flex;
  289. align-items: center;
  290. flex-grow: 1;
  291. margin-left: 60rpx;
  292. .screen_more_text {
  293. font-weight: 700;
  294. font-size: 24rpx;
  295. color: #333333;
  296. margin-right: 10rpx;
  297. }
  298. .screen_more_icon {
  299. width: 30rpx;
  300. height: 30rpx;
  301. }
  302. }
  303. }
  304. .timeDisplay {
  305. font-family: Verdana;
  306. font-size: 24rpx;
  307. color: #666;
  308. line-height: 34rpx;
  309. text-align: right;
  310. margin-top: 5rpx;
  311. margin-right: 20rpx;
  312. min-height: 34rpx;
  313. height: 34rpx;
  314. }
  315. }
  316. </style>