酷炫直播运营系统小程序版本

index.vue 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  1. <template>
  2. <view class="dateplan">
  3. <page-head :slotFlag='true' :bg_jb='true'>
  4. <view class="timeScreen flex" @click="clearToast('monthCalendarFlag')">{{monthInfo.year + '年'+monthInfo.month+'月'}} <view class="iconfont icon-down_icon" style="font-size: 22rpx;margin-left: 10rpx;"></view>
  5. </view>
  6. </page-head>
  7. <view :style="'padding-top:'+ safeAreaTop+'px'">
  8. <!-- 筛选 -->
  9. <view class="screenBox">
  10. <view class="screenBoxFlex">
  11. <view class="accountScreenBox" @click="clearToast('accountShow')">
  12. <image :src="accountInfo.head" mode="widthFix"></image>
  13. <text>{{accountInfo.name}}</text>
  14. <view class="iconfont icon-down_icon"></view>
  15. </view>
  16. <view v-if="userInfo.info.user_control!==0" class="accountScreenBox" @click="clearToast('staffFlag')">
  17. {{staffInfo.id == 0 ? '工作人员' : staffInfo.real_name}} <view class="iconfont icon-down_icon"></view>
  18. </view>
  19. </view>
  20. <user-filter v-if="staffFlag" :staffInfo='staffInfo' @changeUser='changeUser' @clearMask='clearMask'></user-filter>
  21. <account-screen v-if="accountShow" :accountList='accountList' :accountInfo='accountInfo' @changeAccount='changeAccount' @clearMask='clearMask'></account-screen>
  22. </view>
  23. <!-- 日历表头 -->
  24. <view class="dateplanTitle">
  25. <view class="dateplanIcon">
  26. <image @click="backToday" class="dateplanIconImg" src="../../static/img/jintian.png" mode="widthFix"></image>
  27. </view>
  28. <view class="detaplanTitleItem">主播</view>
  29. <view class="detaplanTitleItem">工作人员</view>
  30. </view>
  31. <!-- 日历 -->
  32. <scroll-view class="dateplan_container" :scroll-top='scrollTop' scroll-y="true" @scroll="scroll" :style="'height:calc(100vh - '+ safeAreaTop + 'px - 180rpx)'">
  33. <view :class="['datePlanItem',item.day_format.is_ing?'datePlanIng':'']" v-for="(item,index) in days" :key="index+'days'" :id="item.day_format.now_time?'now_time_box':''">
  34. <view class="timeBox dateplanIcon">
  35. <view class="week" :class="item.day_format.now_time?'c-5B80F4':''">{{item.day_format.week}}</view>
  36. <view class="time" :class="item.day_format.now_time?'c-5B80F4':''">{{item.day_format.day}}</view>
  37. </view>
  38. <view class="addPlan" @click="goEditPlan(index)" v-if="!item.data||!item.data.data||(item.data&&item.data.data&&(item.data.data.length==0 || ((item.data.data.anchor&&item.data.data.anchor.length==0)&&(item.data.data.normal&&item.data.data.normal.length==0))))">
  39. <text v-if="!operationFlag">无计划</text>
  40. <template v-else>
  41. 添加计划
  42. <view class="iconfont icon-tianjia_icon"></view>
  43. </template>
  44. </view>
  45. <view class="itemCon" v-else @click="goEditPlan(index)">
  46. <!-- 主播 -->
  47. <view class="item_worker detaplanTitleItem">
  48. <template v-if="item.data&&item.data.data&&item.data.data.anchor">
  49. <view class="item_worker_con" v-for="(item_anchor,index_anchor) in item.data.data.anchor" :key="index_anchor+'anchor'">
  50. <view class="worker_time" v-if="item_anchor.time">{{item_anchor.time.start_time}}-{{item_anchor.time.end_time}}</view>
  51. <view class="renyuan" v-if="item_anchor.self_staff_list_name">{{item_anchor.self_staff_list_name.join(',')}}</view>
  52. </view>
  53. </template>
  54. </view>
  55. <view class="line"></view>
  56. <!-- 工作人员 -->
  57. <view class="item_worker detaplanTitleItem">
  58. <template v-if="item.data&&item.data.data&&item.data.data.normal">
  59. <view class="item_worker_con" v-for="(item_normal,index_normal) in item.data.data.normal" :key="index_normal+'normal'">
  60. <view class="worker_time" v-if="item_normal.time">{{item_normal.time.start_time}}-{{item_normal.time.end_time}}</view>
  61. <view class="renyuan" v-if="item_normal.self_staff_list_name">{{item_normal.self_staff_list_name.join(',')}}</view>
  62. </view>
  63. </template>
  64. </view>
  65. </view>
  66. </view>
  67. </scroll-view>
  68. </view>
  69. <!-- 月日历 -->
  70. <month-calendar v-if="monthCalendarFlag" :monthInfo='monthInfo' @changeMonth='changeMonth' @clearMask='clearMask'></month-calendar>
  71. <wm-watermark :text="real_name" :opacity="monthCalendarFlag||accountShow||staffFlag?0.1:0.2"></wm-watermark>
  72. </view>
  73. </template>
  74. <script>
  75. import accountScreen from '@/components/account-screen.vue'
  76. import userFilter from '@/components/user-filter.vue'
  77. import monthCalendar from '@/components/month-calendar.vue'
  78. export default {
  79. components: {
  80. accountScreen,
  81. userFilter,
  82. monthCalendar
  83. },
  84. data () {
  85. return {
  86. safeAreaTop: this.$store.state.systemInfo.safeAreaTop,
  87. accountList: [],
  88. accountInfo: {},
  89. weekOrMonth: 'month',
  90. days: [],
  91. seller_id: '', //账号ID
  92. accountShow: false,
  93. staffInfo: { name: '全部', id: 0 },//工作人员
  94. staffFlag: false,
  95. monthCalendarFlag: false,
  96. monthInfo: {
  97. year: '',
  98. month: ''
  99. },
  100. scrollTop: 0,
  101. oldScrollTop: 0,
  102. loadFlag: false,
  103. operationFlag: false,
  104. real_name: '',
  105. userInfo: {},
  106. todayTime:'',
  107. topTodayScroll:0
  108. }
  109. },
  110. async onLoad () {
  111. await this.$onLaunched;
  112. this.real_name = uni.getStorageSync('userInfo').info.real_name;
  113. this.userInfo = uni.getStorageSync('userInfo')
  114. if (this.loadFlag) {//编辑返回时候,刷新接口
  115. console.log('从编辑业来')
  116. this.loadFlag = false
  117. this.init('edit')
  118. } else {//初始化进来时
  119. if (uni.getStorageSync('userInfo').info.is_edit == 1) {
  120. this.operationFlag = true;//是否有编辑权限
  121. }
  122. this.get_accountList('one')
  123. }
  124. },
  125. methods: {
  126. backToday(){//回到今日
  127. if(this.todayTime == (this.monthInfo.year + '-' + this.monthInfo.month)){//当月
  128. this.scrollTop = this.oldScrollTop;
  129. this.$nextTick(() => {
  130. this.scrollTop = this.topTodayScroll
  131. });
  132. }else{
  133. this.initData()
  134. }
  135. },
  136. goEditPlan (index) {//编辑计划
  137. if (!this.operationFlag) return;
  138. let date = this.days[index].data.date;
  139. console.log(this.accountInfo,'accountInfo')
  140. uni.navigateTo({
  141. url: '/pages/dateplan/editPlan?date=' + date + '&head=' + encodeURIComponent(this.accountInfo.head) + '&name=' + this.accountInfo.name + '&platform=' + this.accountInfo.platform + '&ruled=' + this.accountInfo.ruled + '&seller_id=' + this.accountInfo.seller_id
  142. })
  143. this.loadFlag = true
  144. },
  145. scroll (e) {
  146. this.oldScrollTop = e.detail.scrollTop
  147. },
  148. clearToast (type) {
  149. type != 'staffFlag' ? this.staffFlag = false : '';
  150. type != 'accountShow' ? this.accountShow = false : '';
  151. type != 'monthCalendarFlag' ? this.monthCalendarFlag = false : '';
  152. this[type] = !this[type]
  153. },
  154. clearMask () {
  155. this.staffFlag = false;
  156. this.accountShow = false;
  157. this.monthCalendarFlag = false;
  158. },
  159. changeMonth (val) {
  160. this.clearMask()
  161. if (this.monthInfo.year == val.year && this.monthInfo.month == val.month) return;
  162. this.monthInfo = val;
  163. this.initData(this.monthInfo.year + '-' + this.monthInfo.month)
  164. this.scrollTop = this.oldScrollTop;
  165. this.$nextTick(() => {
  166. this.scrollTop = 0
  167. });
  168. },
  169. changeUser (val) {
  170. this.staffInfo = val;
  171. this.staffFlag = false;
  172. this.init()
  173. this.scrollTop = this.oldScrollTop;
  174. this.$nextTick(() => {
  175. this.scrollTop = 0
  176. });
  177. },
  178. changeAccount (val) {
  179. this.accountInfo = val;
  180. this.accountShow = false;
  181. this.init()
  182. this.scrollTop = this.oldScrollTop;
  183. this.$nextTick(() => {
  184. this.scrollTop = 0
  185. });
  186. },
  187. get_accountList (type) {
  188. uni.showLoading({ title: '加载中' });
  189. this.$req(this.$api.user_sellerList, 'get', {}, (res) => {
  190. if (res && res.errno == 0) {
  191. this.accountList = res.rst
  192. if (!this.seller_id || this.seller_id == '') {
  193. this.seller_id = this.accountList[0].seller_id
  194. }
  195. let accountData = this.accountList.filter((v) => {
  196. return v.seller_id == this.seller_id
  197. })
  198. if (accountData && accountData.length > 0) {
  199. this.accountInfo = accountData[0];
  200. } else {
  201. this.accountInfo = this.accountList[0];
  202. this.seller_id = this.accountList[0].seller_id
  203. }
  204. if (type == 'one') {
  205. // 在vue初始化时调用
  206. if (this.weekOrMonth == 'month') {
  207. this.initData()
  208. }
  209. }
  210. } else if (res.errno != 4002) {
  211. uni.hideLoading()
  212. uni.showToast({
  213. title: res.err,
  214. icon: 'none'
  215. });
  216. }
  217. }, (err) => {
  218. uni.hideLoading()
  219. })
  220. },
  221. initData (cur) {
  222. uni.showLoading({ title: '加载中' });
  223. var date
  224. if (cur) {
  225. date = new Date(cur)
  226. } else {
  227. date = new Date()
  228. date = new Date(date.getFullYear() + '-' + ((date.getMonth() + 1) > 9 ? (date.getMonth() + 1) : ('0' +
  229. (date.getMonth() + 1))))
  230. }
  231. let currentYear = date.getFullYear()
  232. let currentMonth = date.getMonth() + 1
  233. this.monthInfo.year = currentYear;
  234. this.monthInfo.month = currentMonth < 9 ? ('0' + currentMonth) : currentMonth;
  235. var str = this.formatDate(currentYear, currentMonth, date.getDate())
  236. let days = [];
  237. //判断每月多少天
  238. var day_num = new Date(currentYear, currentMonth, 0).getDate();
  239. // 数据插入
  240. for (var j = 0; j < day_num; j++) {
  241. var d3 = new Date(str)
  242. d3.setDate(d3.getDate() + j)
  243. days.push({ day_format: this.day_format(d3) })
  244. }
  245. this.days = days
  246. this.init()
  247. },
  248. init (source) {
  249. this.loading = true;
  250. uni.showLoading({ title: '加载中' });
  251. var params = {
  252. type: source == 'week' ? 2 : 1,
  253. staff_id: this.userInfo.info.user_control==0 ? this.userInfo.info.id : this.staffInfo.id, //工作人员
  254. seller_id: this.accountInfo.seller_id, //账号ID
  255. }
  256. // if (source == 'week') {
  257. // params.start_date = this.week_time[0]
  258. // params.end_date = this.week_time[1]
  259. // } else {
  260. params.month = this.monthInfo.year + '-' + this.monthInfo.month
  261. // }
  262. this.$req(this.$api.plan_livePlanListV2, 'get', params, (res) => {
  263. this.loading = false
  264. if (res && res.errno == 0) {
  265. let data_arr = res.rst
  266. uni.hideLoading()
  267. data_arr.forEach((item) => {
  268. if (item.data && item.data.length != 0) {
  269. item.data.anchor.forEach((item1) => {
  270. item1.self_staff_list = item1.staff_list.map((v) => {
  271. return v.staff_id
  272. })
  273. item1.self_staff_list_name = item1.staff_list.map((v) => {
  274. return v.staff_name
  275. })
  276. })
  277. item.data.normal.forEach((item1) => {
  278. item1.self_staff_list = item1.staff_list.map((v) => {
  279. return v.staff_id
  280. })
  281. item1.self_staff_list_name = item1.staff_list.map((v) => {
  282. return v.staff_name
  283. })
  284. })
  285. }
  286. })
  287. this.days.forEach((item, index) => {
  288. this.$set(this.days, index, Object.assign(this.days[index], {
  289. data: data_arr.filter((v) => {
  290. return v.date == item.day_format.date
  291. })[0]
  292. }))
  293. });
  294. this.$nextTick(() => {
  295. if(source != 'edit'){
  296. let query = uni.createSelectorQuery().in(this);
  297. query.select('#now_time_box').boundingClientRect(data => {
  298. if (data&&data.top) {
  299. this.topTodayScroll = Number(data.top) - Number(data.height) - 120;
  300. this.scrollTop = this.topTodayScroll
  301. }
  302. }).exec();
  303. }
  304. })
  305. // this.old_infoList = JSON.parse(JSON.stringify(this.days))
  306. } else if (res.errno != 4002) {
  307. uni.showToast({
  308. title: res.err,
  309. icon: 'none'
  310. });
  311. }
  312. }, (err) => {
  313. uni.hideLoading()
  314. })
  315. },
  316. // 返回 类似 2016-01-02 格式的字符串
  317. formatDate: function (year, month, day) {
  318. var y = year
  319. var m = month
  320. if (m < 10) m = '0' + m
  321. if (day) {
  322. var d = day
  323. if (d < 10) d = '0' + d
  324. }
  325. return y + '-' + m + (day ? ('-' + d) : '')
  326. },
  327. day_format (date) { //返回 类似 2016-01-02 格式的字符串
  328. let week = '';
  329. switch (date.getDay()) {
  330. case 0: week = '周日'; break;
  331. case 1: week = '周一'; break;
  332. case 2: week = '周二'; break;
  333. case 3: week = '周三'; break;
  334. case 4: week = '周四'; break;
  335. case 5: week = '周五'; break;
  336. case 6: week = '周六'; break;
  337. default: week = '';
  338. }
  339. let is_ing = false;//是否是过去式 - 直播过的
  340. let now_time = false;//是否是今天
  341. if (new Date(this.$getDay(0, false)).getTime() > date.getTime()) {
  342. is_ing = true
  343. }
  344. if (new Date(this.$getDay(0, false)).getTime() == date.getTime()) {
  345. now_time = true
  346. this.todayTime = date.getFullYear() + '-' + ((date.getMonth() + 1) < 10 ? ('0' + (date.getMonth() + 1)) : (date
  347. .getMonth() + 1));
  348. }
  349. return {
  350. date: date.getFullYear() + '-' + ((date.getMonth() + 1) < 10 ? ('0' + (date.getMonth() + 1)) : (date
  351. .getMonth() + 1)) + '-' + (date.getDate() < 10 ? ('0' + date.getDate()) : date.getDate()),
  352. date2: ((date.getMonth() + 1) < 10 ? ('0' + (date.getMonth() + 1)) : (date
  353. .getMonth() + 1)) + '-' + (date.getDate() < 10 ? ('0' + date.getDate()) : date.getDate()),
  354. week: week,
  355. day: (date.getDate() < 10 ? ('0' + date.getDate()) : date.getDate()),
  356. is_ing: is_ing,
  357. now_time: now_time
  358. }
  359. },
  360. }
  361. }
  362. </script>
  363. <style scoped lang="scss">
  364. .dateplan {
  365. background: #ffffff;
  366. }
  367. .timeScreen {
  368. color: #ffffff;
  369. font-size: 40rpx;
  370. line-height: 60rpx;
  371. margin-left: 20rpx;
  372. margin-top: 16rpx;
  373. }
  374. .screenBox {
  375. .screenBoxFlex {
  376. padding: 20rpx 20rpx;
  377. display: flex;
  378. align-items: center;
  379. justify-content: space-between;
  380. border-bottom: 2rpx solid #e8e8e8;
  381. }
  382. .accountScreenBox {
  383. display: flex;
  384. align-items: center;
  385. height: 60rpx;
  386. line-height: 60rpx;
  387. background: #f4f6f6;
  388. border-radius: 30rpx;
  389. padding: 0 18rpx;
  390. color: #5f656f;
  391. font-size: 24rpx;
  392. font-weight: bold;
  393. image {
  394. width: 30rpx;
  395. height: 30rpx;
  396. border-radius: 4px;
  397. margin-right: 10rpx;
  398. }
  399. .iconfont {
  400. font-size: 14rpx;
  401. margin-left: 10rpx;
  402. }
  403. }
  404. }
  405. .dateplanTitle {
  406. display: flex;
  407. align-items: center;
  408. height: 78rpx;
  409. box-shadow: 0px 4rpx 8rpx 0px rgba(202, 202, 202, 0.5);
  410. .dateplanIcon {
  411. color: #555555;
  412. font-size: 26rpx;
  413. }
  414. .detaplanTitleItem {
  415. color: #555555;
  416. font-size: 26rpx;
  417. line-height: 78rpx;
  418. }
  419. }
  420. .dateplanIcon {
  421. width: 100rpx;
  422. text-align: center;
  423. }
  424. .detaplanTitleItem {
  425. width: calc(50vw - 50rpx);
  426. padding-left: 30rpx;
  427. }
  428. .dateplan_container {
  429. overflow-y: auto;
  430. }
  431. .datePlanItem {
  432. display: flex;
  433. align-items: flex-start;
  434. margin: 25rpx 0;
  435. margin-right: 12rpx;
  436. .timeBox {
  437. color: #000000;
  438. .week {
  439. font-size: 24rpx;
  440. line-height: 34rpx;
  441. }
  442. .time {
  443. font-size: 48rpx;
  444. line-height: 66rpx;
  445. }
  446. }
  447. .line {
  448. width: 2rpx;
  449. height: 100%;
  450. background: #ffffff;
  451. position: absolute;
  452. left: 0;
  453. right: 0;
  454. margin: auto;
  455. top: 0;
  456. }
  457. .itemCon {
  458. display: flex;
  459. align-items: center;
  460. background: #e4e9fc;
  461. padding: 6rpx 0;
  462. position: relative;
  463. .item_worker {
  464. color: #3048bc;
  465. padding-right: 4rpx;
  466. .renyuan {
  467. font-size: 28rpx;
  468. line-height: 34rpx;
  469. word-break: break-all;
  470. }
  471. .worker_time {
  472. font-size: 24rpx;
  473. line-height: 30rpx;
  474. word-break: break-all;
  475. }
  476. }
  477. .item_worker_con {
  478. margin: 10rpx 0;
  479. }
  480. }
  481. }
  482. .datePlanIng {
  483. .timeBox {
  484. color: #bcc0c3;
  485. }
  486. .itemCon {
  487. background: #f2f6ff;
  488. .item_worker {
  489. color: #aab3df;
  490. }
  491. }
  492. }
  493. .addPlan {
  494. width: 100%;
  495. height: 92rpx;
  496. background: #f8f7f5;
  497. display: flex;
  498. align-items: center;
  499. justify-content: center;
  500. color: #6d6d6d;
  501. font-size: 24rpx;
  502. line-height: 34rpx;
  503. .iconfont {
  504. color: #c8c8c8;
  505. font-size: 26rpx;
  506. margin-left: 17rpx;
  507. }
  508. }
  509. .dateplanIconImg {
  510. width: 40rpx;
  511. height: 40rpx;
  512. margin-top: 6rpx;
  513. }
  514. </style>