|
@@ -8,23 +8,29 @@ Page({
|
|
|
* 页面的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
- sceneList: [{name:'美国',id:0},{name:'中国',id:1},{name:'巴西',id:2},{name:'本',id:3},],
|
|
|
- hostList: [{name:'我的测试主持',id:0},{name:'我的测试主持1',id:1},{name:'我的测试主持2',id:2},{name:'我的测试主持3',id:3},],
|
|
|
- scene: 0,
|
|
|
- host: 0,
|
|
|
- assistant:0,
|
|
|
+ sceneList: [],
|
|
|
+ hostList: [],
|
|
|
+
|
|
|
+ currentUser: {},
|
|
|
dateMinute: '',
|
|
|
- assistantList: [{name:'小黑',id:0},{name:'小白',id:1},{name:'小黄',id:2},{name:'小蓝',id:3},],
|
|
|
- detail:{
|
|
|
- name:'',
|
|
|
- scene:'',
|
|
|
- brandId:'',
|
|
|
- host:'',
|
|
|
- anchorUserId:'',
|
|
|
- assistant:'',
|
|
|
- assistantUserId:'',
|
|
|
- effectiveStartTime:'',
|
|
|
- effectiveEndTime:'',
|
|
|
+ assistantList: [],
|
|
|
+
|
|
|
+ detail: {
|
|
|
+ name: '',
|
|
|
+ scene: "", //直播label
|
|
|
+ brandId: '', //直播场景ID
|
|
|
+ anchorUserId: '', //主持人ID
|
|
|
+ assistantUserId: '', //助理用户iD
|
|
|
+ assistant: "", // 助理label
|
|
|
+ effectiveStartTime: '',
|
|
|
+ effectiveEndTime: '',
|
|
|
+ },
|
|
|
+ fetcherData: {
|
|
|
+ type: 32,
|
|
|
+ address: "",
|
|
|
+ page: 1,
|
|
|
+ size: 20,
|
|
|
+ name: "",
|
|
|
}
|
|
|
},
|
|
|
|
|
@@ -45,8 +51,17 @@ Page({
|
|
|
/**
|
|
|
* 生命周期函数--监听页面显示
|
|
|
*/
|
|
|
- onShow() {
|
|
|
+ async onShow() {
|
|
|
+ this.getAssistantsList();
|
|
|
+ this.getSceneList();
|
|
|
+
|
|
|
+ let user = await wx.getStorageSync('userinfoDetail')
|
|
|
|
|
|
+ this.setData({
|
|
|
+ currentUser: user,
|
|
|
+ "detail.anchorUserId": user.userId
|
|
|
+ })
|
|
|
+ // debugger
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -83,65 +98,119 @@ Page({
|
|
|
onShareAppMessage() {
|
|
|
|
|
|
},
|
|
|
- getSceneList(){
|
|
|
+
|
|
|
+ async getAssistantsList() {
|
|
|
+ try {
|
|
|
+ const res = await util.request(api.getAssistants, this.data.fetcherData, 'POST', 'application/json')
|
|
|
+ console.log('getAssistantsList', res.data);
|
|
|
+ if (res.code === 200) {
|
|
|
+
|
|
|
+ if (Array.isArray(res.data)) {
|
|
|
+ Array.from(res.data).forEach(assistant => {
|
|
|
+ assistant.name = assistant.username
|
|
|
+ assistant.id = assistant.userId
|
|
|
+ })
|
|
|
+ this.setData({
|
|
|
+ assistantList: res.data
|
|
|
+ })
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ } catch (error) {
|
|
|
+ console.log('getAssistantsList::error', error)
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
},
|
|
|
- pickerChange: function(e) {
|
|
|
- const abj ={
|
|
|
- 'scene':this.data.sceneList,
|
|
|
- 'host':this.data.hostList,
|
|
|
- 'assistant':this.data.assistantList,
|
|
|
+ async getSceneList() {
|
|
|
+ try {
|
|
|
+ const res = await util.request(api.BrandList, this.data.fetcherData, 'POST')
|
|
|
+ console.log('getSceneList', res.data.data);
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.setData({
|
|
|
+ sceneList: res.data.data
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (error) {
|
|
|
+ console.log('getSceneList::error', error)
|
|
|
}
|
|
|
- const { type, name } = e.currentTarget.dataset
|
|
|
- let item = abj[name][e.detail.value]
|
|
|
- let detail = this.data.detail
|
|
|
- detail[type] = e.detail.value,
|
|
|
- detail[name] = item.name,
|
|
|
+
|
|
|
+ },
|
|
|
+ pickerChange: function (e) {
|
|
|
+ const abj = {
|
|
|
+ 'scene': this.data.sceneList,
|
|
|
+ 'host': this.data.hostList,
|
|
|
+ 'assistant': this.data.assistantList,
|
|
|
+ }
|
|
|
+ const {
|
|
|
+ type,
|
|
|
+ name
|
|
|
+ } = e.currentTarget.dataset
|
|
|
+ let item = abj[name][e.detail.value];
|
|
|
+ let detail = this.data.detail;
|
|
|
+ detail[type] = e.detail.value;
|
|
|
+ detail[name] = item.name;
|
|
|
+
|
|
|
this.setData({
|
|
|
[name]: item.id,
|
|
|
detail,
|
|
|
- },()=>{
|
|
|
- console.log('picker值为',type, name,detail,item,)
|
|
|
+ }, () => {
|
|
|
+ console.log('picker值为', type, name, detail, item, )
|
|
|
})
|
|
|
},
|
|
|
- sceneChange: function(e) {
|
|
|
- let index = e.detail.value
|
|
|
- console.log('picker值为',index)
|
|
|
+
|
|
|
+ handleRoomName: function (e) {
|
|
|
this.setData({
|
|
|
- index: e.detail.value
|
|
|
+ 'detail.name': e.detail.value
|
|
|
})
|
|
|
},
|
|
|
- hostChange: function(e) {
|
|
|
- let index = e.detail.value
|
|
|
- console.log('picker值为',index)
|
|
|
- this.setData({
|
|
|
- index: e.detail.value
|
|
|
- })
|
|
|
+
|
|
|
+ sceneChange: function (e) {
|
|
|
+ const index = e.detail.value
|
|
|
+ if (index > -1) {
|
|
|
+ const select = this.data.sceneList[index]
|
|
|
+ console.log('picker值为', select)
|
|
|
+ this.setData({
|
|
|
+ 'detail.scene': select.name,
|
|
|
+ "detail.brandId": select.id
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
- assistantChange: function(e) {
|
|
|
- let index = e.detail.value
|
|
|
- console.log('picker值为',index)
|
|
|
- this.setData({
|
|
|
- index: e.detail.value
|
|
|
- })
|
|
|
+
|
|
|
+ assistantChange: function (e) {
|
|
|
+ const index = e.detail.value
|
|
|
+ if (index > -1) {
|
|
|
+ const select = this.data.assistantList[index]
|
|
|
+ console.log('picker值为', select)
|
|
|
+ this.setData({
|
|
|
+ 'detail.assistant': select.username,
|
|
|
+ "detail.assistantUserId": select.userId
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
- /**
|
|
|
+ /**
|
|
|
* 年月日时分选择类型的回调函数,可以在该函数得到选择的时间
|
|
|
*/
|
|
|
selectDateMinuteChange(ev) {
|
|
|
- const { type } = ev.currentTarget.dataset
|
|
|
+ const {
|
|
|
+ type
|
|
|
+ } = ev.currentTarget.dataset
|
|
|
let detail = this.data.detail
|
|
|
detail[type] = ev.detail.value
|
|
|
//判断大小
|
|
|
console.log(detail)
|
|
|
- if(detail.effectiveEndTime && detail.effectiveStartTime){
|
|
|
+ if (detail.effectiveEndTime && detail.effectiveStartTime) {
|
|
|
let value = new Date(detail.effectiveEndTime) - new Date(detail.effectiveStartTime);
|
|
|
- console.log(value,detail.effectiveEndTime ,detail.effectiveStartTime )
|
|
|
- if(value<0){
|
|
|
- return wx.showToast({
|
|
|
- title: '结束时间大于开始时间',
|
|
|
- icon: 'error',
|
|
|
- duration: 1000
|
|
|
+ console.log(value, detail.effectiveEndTime, detail.effectiveStartTime)
|
|
|
+ if (value < 0) {
|
|
|
+ return wx.showToast({
|
|
|
+ title: '结束时间大于开始时间',
|
|
|
+ icon: 'error',
|
|
|
+ duration: 1000
|
|
|
})
|
|
|
}
|
|
|
}
|
|
@@ -155,36 +224,64 @@ Page({
|
|
|
multiIndex: e.detail.value
|
|
|
})
|
|
|
},
|
|
|
- sbmit: async function(){
|
|
|
- const {name,id,brandId,anchorUserId,effectiveStartTime,effectiveEndTime,assistantUserId} = this.data.detail
|
|
|
+ sbmit: async function () {
|
|
|
+ const {
|
|
|
+ name,
|
|
|
+ id,
|
|
|
+ brandId,
|
|
|
+ anchorUserId,
|
|
|
+ effectiveStartTime,
|
|
|
+ effectiveEndTime,
|
|
|
+ assistantUserId
|
|
|
+ } = this.data.detail
|
|
|
+
|
|
|
let err = ''
|
|
|
- if(!brandId){
|
|
|
+ if (!brandId) {
|
|
|
err = '请选择直播场景'
|
|
|
- }else if(!anchorUserId){
|
|
|
+ } else if (!anchorUserId) {
|
|
|
err = '请选择主持人'
|
|
|
- }else if(!anchorUserId){
|
|
|
+ } else if (!anchorUserId) {
|
|
|
err = '请选择主持人'
|
|
|
- }else if(!effectiveStartTime){
|
|
|
+ } else if (!effectiveStartTime) {
|
|
|
err = '请选择开始时间'
|
|
|
- }else if(!effectiveEndTime){
|
|
|
+ } else if (!effectiveEndTime) {
|
|
|
err = '请选择结束时间'
|
|
|
- }else if(!assistantUserId){
|
|
|
+ } else if (!assistantUserId) {
|
|
|
err = '请选择助理'
|
|
|
}
|
|
|
- if(err){
|
|
|
+ if (err) {
|
|
|
return wx.showToast({
|
|
|
- title: err,
|
|
|
- icon: 'error',
|
|
|
- duration: 1000
|
|
|
- })
|
|
|
+ title: err,
|
|
|
+ icon: 'error',
|
|
|
+ duration: 1000
|
|
|
+ })
|
|
|
}
|
|
|
let res = await util.request(api.createOrUpdate, {
|
|
|
- ...this.data.detail
|
|
|
- },"POST")
|
|
|
- if (res.errno == 0) {
|
|
|
- return res.data
|
|
|
- } else if (res.errno == 1) {
|
|
|
- return false
|
|
|
+ name,
|
|
|
+ brandId, //直播场景ID
|
|
|
+ anchorUserId, //主持人ID
|
|
|
+ assistantUserId, //助理用户iD
|
|
|
+
|
|
|
+ effectiveStartTime: new Date(effectiveStartTime).getTime(),
|
|
|
+ effectiveEndTime: new Date(effectiveEndTime).getTime(),
|
|
|
+ }, "POST", 'application/json')
|
|
|
+
|
|
|
+ // debugger
|
|
|
+
|
|
|
+ if (res.code == 200) {
|
|
|
+ wx.showToast({
|
|
|
+ title: '创建成功!!',
|
|
|
+ icon: "success"
|
|
|
+ })
|
|
|
+ // wx.navigateBack({
|
|
|
+ // delta: 0,
|
|
|
+ // })
|
|
|
+
|
|
|
+ } else {
|
|
|
+ wx.showToast({
|
|
|
+ title: res.error || '创建失败!!',
|
|
|
+ icon: "error"
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
})
|