wsy_branch
王壕 2 years ago
parent 8f4aaf384d
commit 85ea1cb4ee

@ -0,0 +1,3 @@
{
"navigationBarTitleText": "接龙信息表单"
}

@ -0,0 +1,164 @@
// pages/list/list.js
Page({
/**
*
*/
data: {
id:"",
property:"",
name:"",
list:[]
},
/**
* --
*/
onLoad: function () {
},
/**
* --
*/
onReady: function () {
},
/**
* --
* Show
*/
onShow: function () {
//这里的this是指窗口而在request中this是指onShow方法(因为是页面调用onShow,onShow调用request),所以要先定义
var that = this;
wx.request({
//后端接口提供的url
url: 'http://localhost:81/dragon/dragonList',
method:'GET',
//需要传入的参数
data:{},
success:function(res :any){
var list = res.data.data;
if(list == null){
//如果获取数据失败,提示使用者
var toastText = '获取数据失败' + res.data.msg;
wx.showToast({
title: toastText,
//显示时长为2s
duration:2000
})
}else{
that.setData({
list:list
})
}
}
})
},
/**
* --
*/
onHide: function () {
},
/**
* --
*/
onUnload: function () {
},
/**
* --
*/
onPullDownRefresh: function () {
},
/**
*
*/
onReachBottom: function () {
},
/**
*
*/
onShareAppMessage: function () {
},
addTask: function(){
wx.navigateTo({
url: '../operation1/operation1',
})
},
//e表示响应的控件
delTask: function(e :any){
var that = this;
//相当于confirm窗口
wx.showModal({
title: '提示',
//这里的变量名需要与响应控件的data-后面的变量名相同
content: '确认要删除['+e.target.dataset.name+']吗?',
success:function(sm){
if(sm.confirm){
wx.request({
url: 'http://localhost:81/dragon/delete',
data: {'id':e.target.dataset.id},
header: {
//默认是 'content-type': 'application/json'要传post的参数必须写成这样要传delete参数则为null
"content-type": "application/x-www-form-urlencoded"
},
method: 'DELETE',
success: function(res:any) {
var result = res.data.success;
var toastText='删除成功';
if(result == true){
that.data.list.splice(e.target.dataset.index,1);
that.setData({
list:that.data.list
});
}else{
toastText = '删除失败';
}
wx.showToast({
title: toastText,
duration:2000
})
},
})
}
}
})
},
submitDragon: function(e:any) {
wx.navigateTo({
url: '../uploadfile/uploadfile',
events: {
// 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
acceptDataFromOpenedPage: function(data:any) {//参数名字随便起,前后页面对应上即可
//对发送回来的数据进行处理
console.log(data)
},
someEvent: function(data:any) {//参数名字随便起,前后页面对应上即可
console.log(data)
}
},
success: function(res) {
// 通过eventChannel向被打开页面传送数据
res.eventChannel.emit('id', {id: e.target.dataset.id })//参数名字随便起,前后页面对应上即可
res.eventChannel.emit('name', {id: e.target.dataset.name })//参数名字随便起,前后页面对应上即可
res.eventChannel.emit('property', {id: e.target.dataset.property })//参数名字随便起,前后页面对应上即可
},
})
//, name: e.target.dataset.name , property: e.target.dataset.property
}
})

@ -0,0 +1,29 @@
<!--pages/list/list.wxml-->
<view class='container'>
<view class='widget'>
<text class='column'>您发布的接龙信息如下:</text>
</view>
<scroll-view scroll-y="true">
<!--遍历list变量名要和js中的名字相同且item是定值不可修改 -->
<block class='widget' wx:for="{{list}}">
<view class='widget'>
<text class='row'>ID:</text>
<text class='row'>{{item.id}}</text>
<text class='column'>名字:</text>
<text class='column'>{{item.name}}</text>
<view>
<text class='column'>信息:</text>
<text class='column'>{{item.property}}</text>
</view>
<text class='column'>时间:</text>
<text class='column'>{{item.deadtime}}</text>
<view>
</view>
<button class="mini-btn" type='plain' size="mini"
bindtap='submitDragon' data-id='{{item.id}}' data-name='{{item.name}}'data-property='{{item.property}}'>提交接龙</button>
</view>
</block>
<button type='primary' bindtap='addTask'>添加接龙信息</button>
</scroll-view>
</view>

@ -0,0 +1,40 @@
/* pages/list/list.wxss */
.container{
display: flex;
flex-direction: column;
justify-content: space-between;
box-sizing: border-box;
padding-top: 10rpx;
padding-bottom: 10rpx;
}
.widget{
position: relative;
margin-top: 5rpx;
margin-bottom: 5rpx;
padding-top: 20rpx;
padding-bottom: 20rpx;
padding-left: 5rpx;
padding-right: 4rpx;
border: rgb(16, 196, 157) 1px solid;
}
.row{
width: 3rem;
display: table-cell;
}
.form-box picker{
margin: 30rpx 30rpx 0 0;
color: rgb(187, 19, 19);
}
.link-row{
width: 5rem;
display: table-cell;
}
.link{
color: blue;
display: inline-table;
}

@ -0,0 +1,3 @@
{
"navigationBarTitleText": "接龙信息列表"
}

@ -0,0 +1,138 @@
// pages/list/list.js
Page({
/**
*
*/
data: {
list:[]
},
/**
* --
*/
onLoad: function () {
},
/**
* --
*/
onReady: function () {
},
/**
* --
* Show
*/
onShow: function () {
//这里的this是指窗口而在request中this是指onShow方法(因为是页面调用onShow,onShow调用request),所以要先定义
var that = this;
wx.request({
//后端接口提供的url
url: 'http://localhost:81/dragon/dragonList',
method:'GET',
//需要传入的参数
data:{},
success:function(res :any){
var list = res.data.data;
if(list == null){
//如果获取数据失败,提示使用者
var toastText = '获取数据失败' + res.data.msg;
wx.showToast({
title: toastText,
//显示时长为2s
duration:2000
})
}else{
that.setData({
list:list
})
}
}
})
},
/**
* --
*/
onHide: function () {
},
/**
* --
*/
onUnload: function () {
},
/**
* --
*/
onPullDownRefresh: function () {
},
/**
*
*/
onReachBottom: function () {
},
/**
*
*/
onShareAppMessage: function () {
},
addTask: function(){
wx.navigateTo({
url: '../operation1/operation1',
})
},
//e表示响应的控件
delTask: function(e :any){
var that = this;
//相当于confirm窗口
wx.showModal({
title: '提示',
//这里的变量名需要与响应控件的data-后面的变量名相同
content: '确认要删除['+e.target.dataset.name+']吗?',
success:function(sm){
if(sm.confirm){
wx.request({
url: 'http://localhost:81/dragon/delete',
data: {'id':e.target.dataset.id},
header: {
//默认是 'content-type': 'application/json'要传post的参数必须写成这样要传delete参数则为null
"content-type": "application/x-www-form-urlencoded"
},
method: 'DELETE',
success: function(res:any) {
var result = res.data.success;
var toastText='删除成功';
if(result == true){
that.data.list.splice(e.target.dataset.index,1);
that.setData({
list:that.data.list
});
}else{
toastText = '删除失败';
}
wx.showToast({
title: toastText,
duration:2000
})
},
})
}
}
})
}
})

@ -0,0 +1,31 @@
<!--pages/list/list.wxml-->
<view class='container'>
<view class='widget'>
<text class='column'>您发布的接龙信息如下:</text>
</view>
<scroll-view scroll-y="true">
<!--遍历list变量名要和js中的名字相同且item是定值不可修改 -->
<block class='widget' wx:for="{{list}}">
<view class='widget'>
<text class='row'>ID:</text>
<text class='row'>{{item.id}}</text>
<text class='column'>名字:</text>
<text class='column'>{{item.name}}</text>
<view>
<text class='column'>信息:</text>
<text class='column'>{{item.property}}</text>
</view>
<text class='column'>时间:</text>
<text class='column'>{{item.deadtime}}</text>
<text class='link-row'>接龙编辑:</text>
<view class='link-row'>
<navigator class='link' url='../operation1/operation1?id={{item.id}}'>编辑</navigator>|
<text class='link' bindtap='delTask' data-id='{{item.id}}' data-index='{{index}}' data-name='{{item.name}}'>删除
</text>
</view>
</view>
</block>
<button type='primary' bindtap='addTask'>添加接龙信息</button>
</scroll-view>
</view>

@ -0,0 +1,40 @@
/* pages/list/list.wxss */
.container{
display: flex;
flex-direction: column;
justify-content: space-between;
box-sizing: border-box;
padding-top: 10rpx;
padding-bottom: 10rpx;
}
.widget{
position: relative;
margin-top: 5rpx;
margin-bottom: 5rpx;
padding-top: 20rpx;
padding-bottom: 20rpx;
padding-left: 5rpx;
padding-right: 4rpx;
border: rgb(16, 196, 157) 1px solid;
}
.row{
width: 3rem;
display: table-cell;
}
.form-box picker{
margin: 30rpx 30rpx 0 0;
color: rgb(187, 19, 19);
}
.link-row{
width: 5rem;
display: table-cell;
}
.link{
color: blue;
display: inline-table;
}
Loading…
Cancel
Save