2 lines
4.8 KiB
JavaScript
2 lines
4.8 KiB
JavaScript
"use strict";const e=require("./common/vendor.js"),n=require("./components/NationalDictionary.js"),i=require("./components/request.js"),t={data:()=>({genders:0,Gender:[{label:"男",value:1},{label:"女",value:2}],Country:n.optionsArray,countrys:"",nameAnchor:"",numberCoins:"",session:"",remarks:"",Display:!1,Hint:!1,datetimesingle:"",id:null,sendingTime:"",filterable:!0,AnchorProfilePicture:""}),mounted(){e.index.getStorage({key:"userinfo",success:e=>{this.id=e.data.id}})},methods:{gender(e){this.genders=e.value,console.log(e)},country(e){this.countrys=e.value,console.log(e)},handleOverlayClick(e){e.target===this.$el&&(this.Display=!1,this.Hint=!1)},open(){this.Display?(this.Display=!1,this.Hint=!1,this.nameAnchor="",this.genders=0,this.numberCoins="",this.remarks="",this.datetimesingle="",this.countrys="",this.session=""):this.Display=!0},blur(n){this.nameAnchor!==n.target.value&&(this.nameAnchor=n.target.value,e.index.showLoading({title:"正在验证主播",mask:!0}),e.index.request({url:"https://python.yolojt.com/api/"+this.nameAnchor,success:n=>{200===n.data.code?(e.index.hideLoading(),e.index.showToast({title:"查询成功",icon:"none",duration:3e3}),this.AnchorProfilePicture=n.data.data):(e.index.hideLoading(),e.index.showToast({title:"未查询到该主播",icon:"none",duration:3e3}))},fail:function(n){e.index.hideLoading(),e.index.showToast({title:"网络请求失败",icon:"none",duration:3e3})}}))},async Publish(){if(""===this.nameAnchor||0===this.genders||""===this.numberCoins||""===this.countrys||""===this.datetimesingle||""===this.session||""===this.AnchorProfilePicture)return void(this.Hint=!0);if(this.remarks.includes(this.nameAnchor))return void e.index.showToast({title:"备注中不能包含主播昵称",icon:"none",duration:2e3});const n=this.datetimesingle.replace(" ","T"),t=Date.parse(n);if(isNaN(t))throw new Error(`Invalid date format: ${this.datetimesingle}`);this.sendingTime=Math.floor(t/1e3);const o=Math.floor(Date.now()/1e3);if(this.sendingTime<o)return void e.index.showToast({title:"日期不能早于当前时间",icon:"none",duration:2e3});e.index.showLoading({title:"发布中...",mask:!0});200===(await i.request({url:"pk/addPkData",method:"POST",data:{anchorId:this.nameAnchor,pkTime:this.sendingTime,sex:this.genders,country:this.countrys,coin:this.numberCoins,remark:this.remarks,senderId:this.id,anchorIcon:this.AnchorProfilePicture,pkNumber:this.session},userInfo:!0})).code?(this.Display=!1,this.Hint=!1,this.nameAnchor="",this.genders=0,this.numberCoins="",this.remarks="",this.datetimesingle="",this.session="",this.AnchorProfilePicture="",e.index.hideLoading(),e.index.showToast({title:"发布成功",icon:"success",duration:2e3})):(e.index.hideLoading(),e.index.showToast({title:"发布失败",icon:"none",duration:2e3}))}}};if(!Array){(e.resolveComponent("wht-select")+e.resolveComponent("uni-number-box")+e.resolveComponent("uni-datetime-picker")+e.resolveComponent("uni-easyinput"))()}Math||((()=>"./uni_modules/wht-select/components/wht-select/wht-select.js")+(()=>"./uni_modules/uni-number-box/components/uni-number-box/uni-number-box.js")+(()=>"./uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.js")+(()=>"./uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.js"))();const o=e._export_sfc(t,[["render",function(n,i,t,o,s,r){return e.e({a:s.Display},s.Display?e.e({b:e.o$1((e=>r.open())),c:e.o$1(((...e)=>n.NameAnchor&&n.NameAnchor(...e))),d:e.o$1(((...e)=>r.blur&&r.blur(...e))),e:""===s.nameAnchor&&!0===s.Hint},(""===s.nameAnchor&&s.Hint,{}),{f:e.o$1(r.country),g:e.p({backgroundColor:"#ffffff",placeholderColor:"#666666",textColor:"#666666",borderColor:"#ffffff",options:s.Country,filterable:s.filterable,placeholder:"请选择国家"}),h:""===s.countrys&&!0===s.Hint},(""===s.countrys&&s.Hint,{}),{i:e.o$1(r.gender),j:e.p({backgroundColor:"#ffffff",placeholderColor:"#666666",textColor:"#666666",borderColor:"#ffffff",options:s.Gender,placeholder:"性别"}),k:0===s.genders},(s.genders,{}),{l:1===s.genders},(s.genders,{}),{m:2===s.genders},(s.genders,{}),{n:0===s.genders&&!0===s.Hint},(0===s.genders&&s.Hint,{}),{o:e.o$1((e=>s.numberCoins=e)),p:e.p({max:9999999999,background:"#03ABA8",modelValue:s.numberCoins}),q:""===s.numberCoins&&!0===s.Hint},(""===s.numberCoins&&s.Hint,{}),{r:e.o$1((e=>s.datetimesingle=e)),s:e.p({type:"datetime","hide-second":"true",modelValue:s.datetimesingle}),t:""===s.datetimesingle&&!0===s.Hint},(""===s.datetimesingle&&s.Hint,{}),{v:e.o$1((e=>s.session=e)),w:e.p({background:"#03ABA8",modelValue:s.session}),x:""===s.session&&!0===s.Hint},(""===s.session&&s.Hint,{}),{y:e.o$1((e=>s.remarks=e)),z:e.p({type:"textarea",placeholder:"备注",maxlength:"-1",modelValue:s.remarks}),A:e.o$1((e=>r.Publish())),B:e.o$1((()=>{})),C:e.n(s.Display?"create-module":"close-animation "),D:e.o$1((e=>r.open()))}):{})}],["__scopeId","data-v-4f0126b2"]]);exports.MiniProgramPage=o;
|