今天是在第二大学远程实习的第十六天,偷偷发个博客记录一下自己的成长哈哈(今天学习二手校园市场项目)
wxml:
<view class="user-operation">
<form bindsubmit="upload" catchreset="formReset">
<view style="min-height: 5px; background: #f5f5f5;"> </view>
<view class="service-content">
<input name="title" placeholder="请输入商品名称" style='padding-left:10px;width: 100%;' />
</view>
<view class="service-content">
<input name="xin" placeholder="请输入新旧程度,如:九成新" style='padding-left:10px;width: 100%;' />
</view>
<view class="service-content2" >
<input name="yuanj" placeholder="请输入商品原价" style='padding-left:10px;border-right:1rpx solid black;' />
<input name="price" placeholder="请输入商品卖价" style='padding-left:20px;' />
</view>
<view style="text-align: center;padding:10px">请选择商品投稿的分类</view>
<radio-group bindchange="radioChange" style="display:flex;flex-direction:row;">
<label wx:for="{{items}}" wx:key="index">
<view style="padding:5px;">
<radio value="{{item.value}}" checked="true"/>
<text>{{item.name}} </text>
</view>
</label>
</radio-group>
<view class="service-content">
<input name="tel" placeholder="请输入联系电话" style='padding-left:10px;width: 100%;' />
</view>
<view class="service-content">
<input name="address" placeholder="请输入交易地址,如:宿舍楼号等" style='padding-left:10px;width: 100%;' />
</view>
<view class="service-content">
<textarea name="intro" bindblur="bindTextAreaBlur" auto-height placeholder="商品使用感受、入手渠道、转手原因..."
style='padding-left:10px;width: 100%;' />
</view>
js:
//发布商品
upload: function (e) {
var that = this
//根据name 的值 获取数据
console.log('查看应该标题等字段的路径',e)
let title = e.detail.value.title
let price = e.detail.value.price
let tel = e.detail.value.tel
let address = e.detail.value.address
let intro = e.detail.value.intro
let xin = e.detail.value.xin
let yuanj = e.detail.value.yuanj
var titlepic = this.data.titlepic
var userid = this.data.userid
var username = this.data.username
var classid= this.data.classid
// console.log('图片路径',titlepic)
// console.log('id',userid)
// console.log('name',username)
console.log('classid',classid)
//检验标题、价格、联系方式、地址是否为空
if (title == "" || price == "" || tel == "" || address == "") {
wx.showModal({
title: '提示',
content: '标题、价格、联系方式、地址均不能为空'
})
} else {
console.log("开始上传信息")
wx.request({
// url: 'http://lmy4.com/ecmsapi/index.php?mod=news&act=up',
url: 'https://xx.uom.cn/ecmsapi/index.php?mod=ershou&act=up',
header: {
"Content-Type": "application/x-www-form-urlencoded"
},
method: 'POST',
//data: Until.json2Form( { name: "上海", value: "1430ec127e097e1113259c5e1be1ba70" }),
data: {
userid: userid,
username: username,
title: title,
price: price,
tel: tel,
address: address,
intro: intro,
xin:xin,
yuanj:yuanj,
titlepic:titlepic,
classid:classid,
xcx_appid:this.data.xcx_appid,
Tu1:this.data.TupianDizhiLiebiao[1],
Tu2:this.data.TupianDizhiLiebiao[2],
Tu3:this.data.TupianDizhiLiebiao[3],
},
success: function (res) {
console.log("request成功,帝国返回的数据是:", res.data)
// console.log("此时的状态是:",res.data.status)
if (res.data.message == "成功") {
that.setData({
status: "提交成功"
})
} else {
that.setData({
status: "提交失败:" + res.data.status
})
}
wx.showModal({
title:'提示',
content: that.data.status,
success (res) {
if (res.confirm) {
//上传成功后返回首页
wx.reLaunch({
url: '/pages/ershou/index',
})
console.log('用户点击确定')
} else if (res.cancel) {
wx.reLaunch({
url: '/pages/upload/upload',
})
console.log('用户点击取消')
}
}
})
},
fail: function (res) {
console.log("提交数据失败!", res)
}
})
}
},
效果: