微信小程序-001-抽签功能-002-新建抽签
生活随笔
收集整理的這篇文章主要介紹了
微信小程序-001-抽签功能-002-新建抽签
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
微信小程序-001-抽簽功能-002-新建抽簽
目錄
- 一、wxml
- 二、js
pages.chouqian.newqian.newqian
一、wxml
<view class="center">活動名稱:</view> <view class="center"><input maxlength="10" placeholder=" 不能為空" bindinput="checkQuestion" placeholder-style="color:#4169E1" placeholder-class="placeholderStyle" style='box-shadow: 0 0 2rpx #272727' /> </view> <text>\n</text> <view class="center">活動選項:</view><block wx:for="{{lists}}" wx:key="index"><view class="center"><input data-index="{{index}}" placeholder="選項" bindinput='bindKeyInput' placeholder-style="color:#4169E1" placeholder-class="placeholderStyle" style='box-shadow: 0 0 2rpx #272727'></input></view><text>\n</text> </block> <view class=" between"><button class='add-li' bindtap='addList' size="mini">添加選項</button><button class='add-li' bindtap='delList' size="mini">刪除選項</button> </view> <text>\n</text><button bindtap="ochou">抽簽</button>二、js
Page({/*** 頁面的初始數據*/data: {lists: [{}, {}],qname: '',rid: '',},/*** 生命周期函數--監聽頁面加載*/onLoad: function (options) {},addList: function () {var lists = this.data.lists;var newData = {};lists.push(newData);//實質是添加lists數組內容,使for循環多一次this.setData({lists: lists,})},delList: function () {var lists = this.data.lists;lists.pop(); //實質是刪除lists數組內容,使for循環少一次this.setData({lists: lists,})},//小決定的名稱checkQuestion(e) {var that = this,val = e.detail.valueconsole.log(val)that.setData({qname: val,})},bindKeyInput(e) {var that = this,val = e.detail.value,index = e.currentTarget.dataset.index,lists = that.data.listsfor (let i in lists) {if (index == i) {lists[i].name = val}}that.setData({lists: lists,})console.log(lists)},ochou: function (e) {var that = this,lists = that.data.listsvar that = this,qname = that.data.qnamevar wid = wx.getStorageSync('wid')console.log('名稱' + qname)console.log(lists)console.log(wid)var value = wx.getStorageSync('wid')if (!value) {var that = thiswx.showModal({title: '提示',content: '你的登錄信息過期了,請重新登錄',})//調用登錄接口} else {if (qname.length > 0 && lists.length > 0 ) {if( lists.length >1){wx.request({url: 'https://ancientcloud.club/wx/newqian',method: 'GET',data: {lists: lists,qname: qname,wid: wx.getStorageSync('wid'),},header: {'Content-Type': 'application/x-www-form-urlencoded'},success: function (res) {//wx.setStorageSync('rid', rid);that.setData({rid: res.data,}) //var rid = wx.getStorageSync('rid'); wx.navigateTo({url: '/pages/chouqian/zroom/zroom?rid=' + res.data.rid});},fail: function (e) {wx.showToast({title: '服務器錯誤',duration: 2000});}})}else{wx.showModal({title: '提示',content: '一個選擇的轉盤,轉不出另一個選擇。',})}}else{wx.showModal({title: '提示',content: '內容和選項不能為空!',})}}} })總結
以上是生活随笔為你收集整理的微信小程序-001-抽签功能-002-新建抽签的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 用计算机弹小星星的教程,职业歌手教你从零
- 下一篇: vue 车牌号校验(含新能源)