你们好,最近小时发现有诸多的小伙伴们对于垃圾分类小程序毕业设计,垃圾分类小程序这个问题都颇为感兴趣的,今天小活为大家梳理了下,一起往下看看吧。
1、打开微信小程序开发工具后,首先我们要做的是先吧小程序的前段页面写好,也就是小程序的wxml文件。
2、主要的查询代码:
3、<view class="formcss">
4、<form bindsubmit="formSubmit" report-submit='true'>
5、<view class='page_row' bindtap="suo">
6、<view class="df search_arr">
7、<icon class="searchcion" color='#00a7f4' size='20' type='search'></icon>
8、<input class="" placeholder="请输入关键字" value="{{searchValue}}" bindinput="searchValueInput"/>
9、</view>
10、<button class='sousuo' formType="submit">查询</button>
11、</view>
12、</form>
13、</view>
14、前台页面写好了,接下来我们就要打开对应的js文件来实现查询功能的这个代码
15、,可以看到查询按钮绑定了一个:<form bindsubmit="formSubmit" report-submit='true'>
16、index.js代码实现:
17、formSubmit:function(e){
18、wx.showLoading({
19、title: '识别中...',
20、})
21、console.log(e.detail.formId)
22、var that = this;
23、wx.request({
24、url: app.globalData.serverUrl + '/laji/api.php?action=ss_forkey',
25、header: {
26、'Content-Type': 'application/x-www-form-urlencoded'
27、},
28、method: 'POST',
29、dataType: 'json',
30、data: {
31、key: this.data.searchValue,
32、formid: e.detail.formId
33、},
34、success: function (res) {
35、console.log(res.data)
36、that.setshowitem();
37、that.setData({ isshowmain:false});
38、if (res.data.typeid==1) {
39、that.setData({ ishowtime1: true});
40、} else if (res.data.typeid == 2) {
41、that.setData({ ishowtime2: true });
42、} else if (res.data.typeid == 3) {
43、that.setData({ ishowtime3: true });
44、} else if (res.data.typeid == 4) {
45、that.setData({ ishowtime4: true });
46、} else {
47、that.setData({ ishownokey: true });
48、}
49、},
50、fail: function (error) {
51、wx.hideLoading();
52、wx.showToast({
53、title: '请求超时',
54、icon: 'loading',
55、duration: 2000
56、});
57、console.log(error)
58、},
59、complete: function () {
60、wx.hideLoading();
61、}
62、})
63、}
64、通过wx.request函数 将用户搜索的垃圾名称提交到小程序的后天处理,后台处理查询完成以后将查询到的结果输出给前台显示,比如我们搜索:“电池”前台将电池传送给后台,查询结果为“有害垃圾” 前台页面我们就展现给用户看:
65、这样垃圾分类查询小程序的 文字查询功能就完成了,至于后台对垃圾分类的检索处理这个数据是怎么来的,我们有很多方法,我用的后台服务是php的。
以上就是垃圾分类小程序这篇文章的一些介绍,希望对大家有所帮助。