• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

微信小程序投票源码

原作者: [db:作者] 来自: [db:来源] 收藏 邀请
微信小程序投票系统的源码,还缺后台,可以扫小程序参观,有需要的可以联系
wxml的
<!--pages/creat_vote/creat_vote.wxml-->
<!--pages/vote/vote.wxml-->
<!--pages/creat_appoint/creat_appoint.wxml-->
<import src="/pages/mytemplate1/mytemplate1.wxml"/>

<view class="input-list">
<view data-name="title" bindtap="changeimge">
  <view class="tem" >
     <image  style="width:100%;height:300rpx;" src="{{hosturl+vote.imgUrls}}" ></image>
  </view>
  <view class="vote-title-mana" data-id="{{idx}}" data-index="{{index}}">
                <view class="row-box-vote">                 
                  <view class="text" data-index="{{idx}}" data-indexx="{{index}}">换图</view>
                </view>                 
  </view> 
</view>

   <view class="input-item">
        <view class="row-box">
          <text class="input-item-label">投票活动标题</text>
        </view>
          <view class="input-item-content">
            <input data-name="vote_name" type="text" data-index="{{idx}}" value="{{vote.Name}}" bindinput=\'bindinput\' placeholder="输入活动名称"></input>
          </view>
    </view>

      <view class="input-item input-item-full">
          <view class="row-box">
           <view class="red-bj" wx:if="{{item.need}}">*</view>
           <view><text class="input-item-label">简介</text></view>
         </view>
          <textarea  data-name="vote_descri" bindinput="bindinput" maxlength="-1" auto-height="true" data-index="{{idx}}" placeholder="活动说话、投票规则等" value="{{vote.Descri}}"></textarea>
        </view>


 
  <!--编辑规则时间点设置--> 
<view>
 <view class="input-item"> 
  <veiw class="page__title"><text>规则设置</text></veiw>   
   <view class="row-box">           
 <block wx:if="{{!unit_setup.ispart}}">
  <view class="tui-col-5b">
   <view>开始时间:</view>
   <picker data-name="Star_datetime" mode="multiSelector" bindchange="bindMultiPickerChange" bindcolumnchange="bindMultiPickerColumnChange" value="{{multiIndex}}" range="{{multiArray}}">
    <view class="apppoint-pickbox-vote">
      {{vote.Star_datetime}}
    </view>
  </picker>
  </view>

  <view class="tui-col-5b">
   <view>结束时间:</view>
   <picker data-name="End_datetime" mode="multiSelector" bindchange="bindMultiPickerChange" bindcolumnchange="bindMultiPickerColumnChange" value="{{multiIndex}}" range="{{multiArray}}">
    <view class="apppoint-pickbox-vote">
      {{vote.End_datetime}}
    </view>
  </picker>
 </view> 
</block>   
   <view class="tui-col-5a">
      <view>一天</view>
        <label class="exam-radio">
        <radio data-name="one_date" data-index="{{idx}}" bindtap="checkboxchang" checked="{{vote.Count_way==1}}"/>
       </label>
       <view>总共</view>
        <label class="exam-radio">
        <radio data-name="all_date" data-index="{{idx}}" bindtap="checkboxchang" checked="{{vote.Count_way==0}}"/>
       </label>
   </view>  
   
   <view class="tui-col-5a">
     <view>可投票次数:</view>
     <input data-name="Vote_count"  data-index="{{idx}}" class="appoint-input" type="number" value="{{vote.Vote_count}}" bindinput=\'bindinput\'></input>
   </view>      


 <view class="tui-col-5a">
   <view>是否显示得票数:</view>
       <label class="checkbox">
        <checkbox data-name="Ishide_Item_VoteTotal" data-index="{{idx}}" bindtap="checkboxchang" checked="{{vote.Ishide_Item_VoteTotal===1}}"/>
       </label>
  </view>

  <view class="tui-col-5a">
   <view>是否有简介页:</view>
       <label class="checkbox">
        <checkbox data-name="Ishas_Descri" data-index="{{idx}}" bindtap="checkboxchang" checked="{{vote.Ishas_Descri===1}}"/>
       </label>
  </view>

  
    <view class="tui-col-5a">
       <view>正在进行:</view>
       <label class="checkbox">
        <checkbox data-name="Is_service" data-index="{{idx}}" bindtap="checkboxchang" checked="{{vote.Is_service===1}}"/>
       </label>
     </view>

     <view class="tui-col-5a">
      <view>单分类</view>
        <label class="exam-radio">
        <radio data-name="onecategory" data-index="{{idx}}" bindtap="checkboxchang" checked="{{vote.One_or_mult_category==0}}"/>
       </label>
       <view>多分类</view>
        <label class="exam-radio">
        <radio data-name="multcategory" data-index="{{idx}}" bindtap="checkboxchang" checked="{{vote.One_or_mult_category==1}}"/>
       </label>
   </view>  

  </view> 

 </view>
</view>
  <view>
        <block wx:for=\'{{vote.Vote_item}}\' wx:key=\'form_field_id\' wx:for-item="item" wx:for-index="idx" data-index=\'{{form_field_id}}\'>        
         <template is="{{item.typename}}edit" data="{{item,idx,datetime,hosturl,vote,istemaddress}}"/>     
        </block> 
  </view>       
  <view wx:if="{{vote.One_or_mult_category==1}}"><button type="primary" bindtap="addcategory" style="width:100%;#78C652;">添加分类</button></view>
    <!--模板方式调入机构设置-->
  

<!--mask-->
<view class="drawer_screen" bindtap="powerDrawer" data-statu="close" wx:if="{{showModalStatus}}"></view>
  <!--content-->
  <!--使用animation属性指定需要执行的动画-->
 <view animation="{{animationData}}" class="drawer_box" wx:if="{{showModalStatus}}">
  <view  class="showwin" data-name="child" bindtap="changeimge">
    <image  style="width:400rpx;height:400rpx;" src="{{hosturl+select_item_child.image_addree}}"></image>
  </view>
               <view class=\'listItem\'>
               
                <view class="input-item">
                   <view class="row-box">           
                   
                      <view class="vote-text"><text>名称:</text></view>
                    <input data-name="item_child.name"  class="vote-title-input" type="text" data-index="{{idx}}" value="{{select_item_child.name}}" bindinput=\'bindinput\' placeholder="输入名称"></input>                 
                </view>
                <view class="row-box">
                   <view class="vote-text"><text>机构名称:</text></view>
                 <input data-name="organ_name"  class="vote-title-input" type="text" data-index="{{idx}}" value="{{select_item_child.unit}}" bindinput=\'bindinput\' placeholder="输入名称"></input>                 
             </view>
               </view>
             </view>
            
   <veiw class="row-box2">
   <view data-comname="edit_child" class="btn_ok"  bindtap="powerDrawer" data-statu="close">取消</view>
   <view data-comname="edit_child" class="btn_ok" bindtap="powerDrawer" data-statu="change">确定</view>
  </veiw>
 </view>

 <!--mask-->
<view class="drawer_screen" bindtap="powerDrawer" data-statu="close" wx:if="{{showModalStatus1}}"></view>
  <!--content-->
  <!--提交发布的对话框属性指定需要执行的动画-->
 <view animation="{{animationData1}}" class="drawer_box" wx:if="{{showModalStatus1}}">
  <view class="input-list"> 
            <view class="input-item">
             <text class="input-item-label">表单标题:</text>
             
              
          </view>
          <view class="input-item">
          <view hidden="{{Isfromtemplate}}" class="input-item-content">
            <label class="checkbox">
             <checkbox value="cb" data-index="{{idx}}" bindtap="istemplatecheck" checked="{{CheckStatus}}"/>作为公共模板提供他人使用
            </label>
          </view>
          <view class="input-item-content">
            <label class="checkbox">
             <checkbox value="Canmulti" data-index="{{idx}}" bindtap="Canmulti" checked="{{Canmulti}}"/>单个用户可录入多条记录
            </label>
          </view>
          <view class="input-item-content">
            <label class="checkbox">
             <checkbox value="Isclose" data-index="{{idx}}" bindtap="Isclose" checked="{{Isclose}}"/>停止更改、录入
            </label>
          </view>
          <view class="input-item-content">
            <label class="checkbox">
             <checkbox value="Isclose" data-index="{{idx}}" bindtap="Canchang" checked="{{Isclose}}"/>提交后数据可修改
            </label>
          </view>
        </view>
      </view>
   <veiw class="row-box2">
   <view data-comname="build" class="btn_ok"  bindtap="powerDrawer" data-statu="close">取消</view>
   <view data-comname="build" class="btn_ok" bindtap="powerDrawer" data-statu="build">确定</view>
  </veiw>
 </view>

     <view class="height_box"></view> 
     <view class="height_box"></view> 
     <view class="height_box"></view> 
     <view class="height_box"></view> 
</view>
<view class="height_box"></view> 
<view class="height_box"></view> 
 <!--底部-->

    <view hidden="{{viewShowed2}}" class="cart-tab-wrp" style=\'bottom:{{inputBottom}}px\'>     
      <view  class="nav-tab-item3 {{selectedcom==\'add\'?\'nav-tab-item_text\':\'\'}}" hover-class="navigator-hover" bindtap="testabc"><image  src="{{selectedcom==\'add\'?\'../images/add_02.png\':\'../images/icon_23.png\'}}"></image><text>预  览</text></view> 
    
     
       <view data-comname="build" class="nav-tab-item3  {{selectedcom==\'ok\'?\'nav-tab-item_text\':\'\'}}" hover-class="navigator-hover" bindtap="powerDrawer" data-statu="open"><image  src="{{selectedcom==\'ok\'?\'../images/ok_02.png\':\'../images/ok_01.png\'}}"></image><text>提交发布</text></view>     
    </view>



js的
 
import mcommon from \'../../utils/util\'
var QQMapWX = require(\'../../utils/qqmap-wx-jssdk.js\');
var qqmapsdk;
const app = getApp();
var sysdata=app.globalData.api.sysdata();
var arrays=[];//为多级下拉框定义
var fielidex=0;//为多级下拉框定义
var listseachindex=-1;//下拉搜索框下标
var datetime=mcommon.formatTime(new Date());
Date.prototype.format = function (fmt) {
  var o = {
      "M+": this.getMonth() + 1, //月份
      "d+": this.getDate(), //日
      "h+": this.getHours(), //小时
      "m+": this.getMinutes(), //分
      "s+": this.getSeconds(), //秒
      "q+": Math.floor((this.getMonth() + 3) / 3), //季度
      "S": this.getMilliseconds() //毫秒
  };
  if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  for (var k in o)
      if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  return fmt;
}
//用于时期时间选择控件的方法
const date = new Date();
const years = [];
const months = [];
const days = [];
const hours = [];
const minutes = [];
//获取年
for (let i = date.getFullYear(); i <= date.getFullYear() + 1; i++) {
  years.push("" + i);
}
//获取月份
for (let i = 1; i <= 12; i++) {
  if (i < 10) {
    i = "0" + i;
  }
  months.push("" + i);
}
//获取日期
for (let i = 1; i <= 31; i++) {
  if (i < 10) {
    i = "0" + i;
  }
  days.push("" + i);
}
//获取小时
for (let i = 0; i < 24; i++) {
  if (i < 10) {
    i = "0" + i;
  }
  hours.push("" + i);
}
//获取分钟
for (let i = 0; i < 60; i++) {
  if (i < 10) {
    i = "0" + i;
  }
  minutes.push("" + i);
}


Page({

  /**
   * 页面的初始数据
   */
  data: {
    time: \'\',
    multiArray: [years, months, days, hours, minutes],
    multiIndex: [0, 9, 16, 10, 17],
    choose_year: \'\',

    imgUrls_back:"/UploadFiles/2028/img/2021/8/12/d17c80cf2f87418c95fce8e5736a2958_.jpg",
    imgUrls:"/UploadFiles/2028/img/2021/8/12/d75103fb0c5b4af0825a7be73d6d0bdc_.jpg",
    big_imgUrls:"",
    istemaddress:false,
    select_category_index:0,
    select_item_index:0,
    sysuserid:sysdata.sysuserid,
    hosturl:sysdata.hosturl2,
    vote:{
      Idstr:\'\',
      Organ_no:\'1213\',
      Userid:0,
      Name:\'\', 
      Descri:\'\',
      Star_datetime:\'\',
      End_datetime:\'\',//结束时间字符串
      Vote_item:[],//提交时,要转成string
      Ishas_Descri:0,//是否有简介页
      Count_way:1,//一个用户可投票次数,1为每天N次,N为下方列,0为总共N次
      Vote_count:1,//对应上方,可投票次数
      Ishide_Item_VoteTotal:1,//是否显示得票数,默认显示

      Creat_datatime:\'\',
      Is_needtest:0,//是否需要验证,这个后面再搞了
      Exam_code:\'2323\',//验证串码,似乎没有用
      QrCodeurl:\'112\',//二维码地址
      Is_service:1,//1正在进行,,0,停止
      One_or_mult_category:0,//0单分类,1多分类
      Total_item:\'\',//参选统计
      Total_voted:0,//总投票数
      Total_visited:0,//访问量
      imgUrls_back:"/UploadFiles/2028/img/2021/8/12/d17c80cf2f87418c95fce8e5736a2958_.jpg",
      big_imgUrls_back:"",
      imgUrls:"/UploadFiles/2028/img/2021/8/12/d75103fb0c5b4af0825a7be73d6d0bdc_.jpg",
      big_imgUrls:"",
    },
    vote_item:{
         id:0,
         selected:false,//是否选择,用于上移下移
         typename:\'vote\',
         name:\'\',
         one_or_mult:0,//单选或多选,0,单选,1,多选
         maxnum:1,//多选时,最多可选多少个
         has_vote_count:0,//个人用户记录,已经给多少个投了票,这个是对于多选的,只记录当天的
         vote_item_child:[

         ]
    },//大的框架
    vote_item_child:{
      id:0,
      has_voted:false,
      name:\'小奶狗\',
      name:\'小奶狗\',
      unit:\'光明\',//单位
      image_addree:\'/sysfile/images/ng1.jpg\',//图片地址
      big_image_addree:\'/sysfile/images/ng1.jpg\',
      descri:\'\',//简介
      vote_count:0,//得票数
      rank:0,//排名
      exten_mess:\'\',//预留扩展信息
    },//本地使用,添加到
    select_item_child:{},
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options)
    var that=this;
    let frompage="";//哪里转过来的,模板还是修改表单
    var conetcode="";
    var voteid =0
     voteid = options.formtableid || decodeURIComponent(options.scene);
    var userinfo=app.globalData.users;
    var userid=userinfo.userid;
    //console.log(userid)
  
    this.setData({
      choose_year: this.data.multiArray[0][0]
    })
    console.log(voteid)
    if(voteid!=="undefined"&&voteid!==0&&voteid!==null)
    {
     
        that.GetVote(voteid);
    }else
    {
      that.vote_sys();
      that.addcategory();
    }   
  },
//更换页头的图片
chang_image:function(e)
{

},

async testabc(){
  var that=this;
  var userinfo=app.globalData.users;
  var userid=userinfo.userid;
 // var userid=await that.getuserinfo1();
 console.log(userid);
 if(userid==-1||userid===null||userid==="undefined")
 {
  wx.showModal({
    title: \'提示\',
    content: \'将覆盖已有数据,请输入数据更改较验码!\',
    showCancel:true,
    success (res) {
      if (res.confirm) {            
        userid=that.getuserinfo1();     
   }
  }
 })
   
 }
},
 
 async getuserinfo1()
  {
    var that=this;
     var userid=-1;
    await app.AnginLogin1();
     wx.showLoading({
      title: \'登录中\',
     })  
     setTimeout(function () {
      var userinfo=app.globalData.users;
      userid=userinfo.userid;
     
       wx.hideLoading()   
    
     }, 2000)    
    return userid;
  },
 //表投票主表
 async GetVote(voteid)
 {
   var that=this;
   var data={
     "id":voteid
   }
   var url=sysdata.hosturl+\'GetVote\';
   var backdata= await app.globalData.api.getRequest(url,data);
   console.log(backdata)
   if(backdata.data)
   {   
    
  // var conetcode=backdata.data[0].Idstr;
  that.data.vote=backdata.data.votelist[0]
   
  that.data.vote.Vote_item=JSON.parse(backdata.data.votelist[0].Vote_item)
  
  
   that.setData({
       vote:that.data.vote
     
   })
  // that.getappointlist(conetcode)
 }


   console.log(backdata)
 },
  
  //制作serial_no
getserial_no:function()
{
  var datetimestr=mcommon.formatTime1(new Date())
  var rannum=mcommon.getRanNum();
  return datetimestr+rannum
},
  //这个是更新
  add_vote:function(){
    var that = this;
    var userid=-1;
   // var idstr=that.getserial_no();
   var url=sysdata.hosturl+\'Vote_change\';//这个是去添加的
   // var url1= sysdata.hosturl+\'Appoint_change\';//这个是去添加的
     
    var userinfo=app.globalData.users;
  //  var twoarray=that.data.twoarray;
     userid=userinfo.userid;
     if(userid==-1)
     {
       userid=that.getuserinfo1();
     }else{
      var datetime=new Date();
      var datetimestr=datetime.format("yyyy-MM-dd hh:mm:ss")
      var vote_item=that.data.vote.Vote_item;
      var Total_item=0;
      for(let i=0;i<vote_item.length;i++)
      {
          Total_item=Total_item+vote_item[i].vote_item_child.length;
      }
  //  var data={}
    var data=that.data.vote;

     
   // data.Idstr=idstr;
    data.Userid=userid;
    data.Total_item=Total_item;
    data.Creat_datatime=datetimestr;
  //  data.Id=0;
    if(data.Name==="")
    {
      wx.showToast({
        title:\'标题不能为空\',  //标题
        icon: \'success\',       //图标 none不使用图标,详情看官方文档
        duration: 2000
    })
    }
    else{
      wx.showModal({
        title: \'提示\',
        content: \'将覆盖已有数据,请输入数据更改较验码!\',
        showCancel:true,
        success (res) {
          if (res.confirm) {
            data.Vote_item=JSON.stringify(data.Vote_item) 
            that.postdata9(url,data);
          // that.clearStorage(that.data.formtableid);
       }
      }
     })
    }
    
 //}
 }
},
async postdata9(url,data)
{
  var that=this;
  
  console.log(url)
  console.log(data)
 var backdata= await app.globalData.api.getRequest(url,data);
 console.log(backdata) 
 var  workscomstr="vote"
 if(backdata.data.result=="OK")
 {   
  var senddata={
     formtableid:backdata.data.Id,
     qrcodeurl:backdata.data.QrCodeurl,
     formtabletitle:that.data.vote.Name,
     workscomstr:workscomstr
  }
  
  var url1="../share/share?senddata="+JSON.stringify(senddata);
  wx.showModal({
    title: \'提示\',
    content: \'成功创建表单\',
    showCancel:true,
    success (res) {
      if (res.confirm) {
        wx.navigateTo({
          url: url1,
         })
      }
    }
    })
 }
 
},

  //初始化
  vote_sys:function(){
    var that=this;
    var now=new Date();
    //parseInt(endtimeStrs [0], 10);
    var month=now.getMonth();
    var day=now.getDate()    
    var hours=now.getHours()
    var minutes=now.getMinutes()
    var seconds=now.getSeconds()
    var nowstr=now.format("yyyy-MM-dd hh:mm:ss")
    that.data.multiIndex= [0, month, day-1, hours, minutes]

    var enddatetime=now
    enddatetime.setDate(now.getDate()+3)
    var enddatetimestr=enddatetime.format("yyyy-MM-dd hh:mm:ss")
    that.data.vote.Star_datetime=nowstr;
    that.data.vote.End_datetime=enddatetimestr;
    var idstr=that.getserial_no();
    that.data.vote.Idstr=idstr;
    that.setData({
      vote:that.data.vote,
      multiIndex:that.data.multiIndex
    })
  },
  //分类上移选择的字段
  item_moveup:function(e)
  {
    var that=this;
    var index=e.currentTarget.dataset.index;
    //var indexx=e.currentTarget.dataset.indexx;
   
    if(index>0)
    {
       that.data.vote.Vote_item.splice(index-1,0,that.data.vote.Vote_item[index])
       that.data.vote.Vote_item.splice(index+1,1)
       that.setData({
        vote:that.data.vote,
        })
    }
  },
  //分类下移
  item_movedown:function(e)
  {
    var that=this;
    var index=e.currentTarget.dataset.index;
   // var indexx=e.currentTarget.dataset.indexx;
   
    if(index<that.data.vote.Vote_item.length-1)
    {
      that.data.vote.Vote_item.splice(index+2,0,that.data.vote.Vote_item[index])
      that.data.vote.Vote_item.splice(index,1)
    that.setData({
      vote:that.data.vote,
     })
   }
  },
  //上移选择的字段
  moveup:function(e)
  {
    var that=this;
    var index=e.currentTarget.dataset.index;
    var indexx=e.currentTarget.dataset.indexx;
   
    if(indexx>0)
    {
       that.data.vote.Vote_item[index].vote_item_child.splice(indexx-1,0,that.data.vote.Vote_item[index].vote_item_child[indexx])
       that.data.vote.Vote_item[index].vote_item_child.splice(indexx+1,1)
       that.setData({
        vote:that.data.vote,
        })
    }
  },
  //下移
  movedown:function(e)
  {
    var that=this;
    var index=e.currentTarget.dataset.index;
    var indexx=e.currentTarget.dataset.indexx;
   
    if(indexx<that.data.vote.Vote_item[index].vote_item_child.length-1)
    {
      that.data.vote.Vote_item[index].vote_item_child.splice(indexx+2,0,that.data.vote.Vote_item[index].vote_item_child[indexx])
      that.data.vote.Vote_item[index].vote_item_child.splice(indexx,1)
    that.setData({
      vote:that.data.vote,
     })
   }
  },
  //确定修改
  change_item:function(){
     var that=this;
     var select_category_index=that.data.select_category_index;
     var select_item_index=that.data.select_item_index;
     that.data.vote.Vote_item[select_category_index].vote_item_child[select_item_index]=JSON.parse(JSON.stringify(that.data.select_item_child))
     that.setData({
         vote:that.data.vote
     }) 
  },
  //弹窗文本框处理
  bindinput:function(e)
{
  console.log(e)
  var that=this;
    var name=e.currentTarget.dataset.name;
    var index=e.currentTarget.dataset.index;
    switch(name)
      {
          case "vote_name":
          that.data.vote.Name=e.detail.value
          break 
          case "vote_descri":
           that.data.vote.Descri=e.detail.value
          break 
          case "item_child.name":
            that.data.select_item_child.name=e.detail.value
          break         
          case "organ_name":
            that.data.select_item_child.unit=e.detail.value
           break
           case "Vote_count":
            that.data.vote.Vote_count=e.detail.value
            break
          case "maxnum":
            that.data.vote.Vote_item[index].maxnum=e.detail.value
            break   
          case "item_name":
            that.data.vote.Vote_item[index].name=e.detail.value
            break       
      }
  that.setData({
    select_item_child: that.data.select_item_child,
    vote:that.data.vote
  });
 
},  
//接口
comman:function(fileTemp,name)
{
  var that=this;
  var temstr=that.data.select_item_child.image_addree;
  var temstr1=that.data.vote.imgUrls;
  switch(name)
  {
    case "child":
      var temstr=that.data.select_item_child.image_addree;
      var data= {
        "filePath":that.data.select_item_child.big_image_addree,
        "Sm_filePath":that.data.select_item_child.image_addree   
         };
      if(temstr!=="/sysfile/images/ng1.jpg")
      {
         that.del_image(fileTemp,data)
      }
      else{
       
        that.uploadImag(fileTemp,name)
      }
      break;
    case "title":
      var temstr1=that.data.vote.imgUrls;
      var data1= {
        "filePath":that.data.vote.big_imgUrls,
        "Sm_filePath":that.data.vote.imgUrls
         };
      if(temstr1!=="/UploadFiles/2028/img/2021/8/12/d75103fb0c5b4af0825a7be73d6d0bdc_.jpg")
      {
         that.del_image(fileTemp,data1,name)
      }
      else{
       
        that.uploadImag(fileTemp,name)
      }
      break;
  }
 
},
//先删除已经在图片
async del_image(fileTemp,data,name){
  var that=this;
  var  url= sysdata.hosturl+\'DeledFilecom\';
  
     wx.showLoading({
      title: \'上传中\',
    });
    console.log(data)
  var backdata=await app.globalData.api.getRequest(url,data);
  wx.hideLoading();
  console.log(backdata); 
  that.uploadImag(fileTemp,name);
},
//上传图片
async  uploadImag(fileTemp,name){
  var that=this;
  var userinfo=app.globalData.users;
  var userid=userinfo.userid;
  var url=sysdata.hosturl+\'UploadImageFile?address=img\';     
  var data={ 
    "NO":"1234567890",
    "filename":that.data.vote.Name,
    "Userid":userid
};
  wx.showLoading({
    title: \'上传中\',
  });
var backdata=await app.globalData.api.uploadfile(url,fileTemp,data);
wx.hideLoading();
console.log("wait comeback");  
console.log(backdata); 
var backobj=JSON.parse(backdata.data)
switch(name)
{
  case "child":
    that.data.select_item_child.image_addree=backobj.Sm_FilePath;
    that.data.select_item_child.big_image_addree=backobj.FilePath;                       
    that.setData({                    
           select_item_child: that.data.select_item_child,
      });
    break;
  case "title":
    that.data.vote.imgUrls=backobj.Sm_FilePath;
    that.data.vote.big_imgUrls=backobj.FilePath;                       
    that.setData({                    
           vote: that.data.vote,
      });
    break;
}

},      
  //更换图片
  changeimge:function(e){
    var that=this;
    console.log(e)
    var name=e.currentTarget.dataset.name;
    wx.chooseImage({  
      count: 1,          
      sizeType: [\'original\'],
      sourceType: [\'album\', \'camera\'], // 可以指定来源是相册还是相机,默认二者都有
        success: function (res) {                // 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片
          console.log(res);
          var tempFilesSize = res.tempFiles[0].size;
             if(tempFilesSize <= 10200000){   //图片小于或者等于5M时 可以执行获取图片
              var tempFilePaths = res.tempFilePaths;
              
             // that.del_image(tempFilePaths[0])
              that.comman(tempFilePaths[0],name);
            // var temselect_item_child=JSON.parse(JSON.stringify) 
             
             }else{    //图片大于2M,弹出一个提示框
                 wx.showToast({
                     title:\'上传图片不能大于5M!\',  //标题
                     icon:\'none\'       //图标 none不使用图标,详情看官方文档
                 })
             }


        }
    })
  },
  //编辑项目
  edit_item:function(e){
    var that=this;
    var index=e.currentTarget.dataset.index;
    var comname=e.currentTarget.dataset.comname;
    var indexx=e.currentTarget.dataset.indexx;
    var select_item_child=JSON.parse(JSON.stringify(that.data.vote.Vote_item[index].vote_item_child[indexx]))
    that.setData({
     select_category_index:index,
     select_item_index:indexx,
     select_item_child:select_item_child,
    })
    console.log(that.data.select_category_index,that.data.select_item_index)
    var currentStatu="open"
    this.util(currentStatu,comname)
  },
  //弹窗提示
powerDrawer: function (e) {
  console.log(e)
  var currentStatu = e.currentTarget.dataset.statu;
  var comname=e.currentTarget.dataset.comname;
  var that = this;
  var userid=-1; 
  var userinfo=app.globalData.users;
   userid=userinfo.userid;
   if(userid==-1)
   {
     userid=that.getuserinfo1();
   }
  

 this.util(currentStatu,comname)
},

util: function (currentStatu,comname) {
  var that=this;
  var animation = wx.createAnimation({
  duration: 200,
  timingFunction: "linear",
  delay: 0
  });
  this.animation = animation;
  animation.opacity(0).rotateX(-100).step();
  if(comname==="edit_child"){
    this.setData({
      animationData: animation.export()
     })
  }
  else if(comname==="build")
  {
    this.setData({
      animationData1: animation.export()
     })
  }
 
 
setTimeout(function () 
{
   animation.opacity(1).rotateX(0).step();
   if(comname==="edit_child"){
    this.setData({
      animationData: animation
     })
  }
  else if(comname==="build")
  {
    this.setData({
      animationData1: animation
     })
  }
  if (currentStatu == "close") 
  {
    this.setData({
   showModalStatus: false,
   showModalStatus1: false
   });
  } 
  if (currentStatu == "build") 
  {
    that.add_vote();
    this.setData({
    showModalStatus1: false
   });
  } 
  if (currentStatu == "change") 
  {
    that.change_item();
    this.setData({
   showModalStatus: false,
  
   });
  } 
}.bind(this), 200)

if (currentStatu == "open") {
  if(comname==="edit_child"){
    this.setData({
      showModalStatus: true
     })
  }
  else if(comname==="build")
  {
    this.setData({
      showModalStatus1: true
     })
  }

}
},
  //设置的选择框方法
  checkboxchang:function(e){
    var that=this;
    var nam

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
微信小程序列表加载更多 - demo例子集发布时间:2022-07-18
下一篇:
微信步数日历打卡小程序全栈项目源码+****发布时间:2022-07-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap