E企盈营销工具技术服务商 热线:4006-838-530

微信机器人免费版,微信小程序智能机器人

E企盈直播平台营销卖货系统

github地址:https://github.com/HowName/smart-robot项目为智能应答机器人,使用了图灵机器人接口,慢慢调戏吧-首页,主要处理页:1//index.js23varapp=getApp();4varthat;5varchatListData=[];67Page({8data:{9askWord:”,10userInfo:{},11chatList:[],12},13onLoad:function(){14that=this;15//获取用户信息16app.getUserInfo(function(userInfo){17that.setData({18userInfo:userInfo19});20});21},22onReady:function(){23//问候语24setTimeout(function(){25that.addChat(‘你好啊!’,’l’);26},1000);27},28sendChat:function(e){2930letword=e.detail.value.ask_word?e.detail.value.ask_word:e.detail.value;//支持两种提交方式31that.addChat(word,’r’);3233//请求api获取回答34app.req(‘post’,’openapi/api’,{35’data’:{‘info’:word,’loc’:’广州’,’userid’:’123′},36’success’:function(resp){37that.addChat(resp.text,’l’);38if(resp.url){39that.addChat(resp.url,’l’);40}41},42});4344//清空输入框45that.setData({46askWord:”47});48},49//新增聊天列表50addChat:function(word,orientation){51letch={‘text’:word,’time’:newDate().getTime(),’orientation’:orientation};52chatListData.push(ch);53that.setData({54chatList:chatListData55});56}57})-页面:1//index.wxml23view4scroll-viewscroll-y=”true”5view6blockwx:for=”{{chatList}}”wx:key=”time”7viewwx:if=”{{item.orientation==’l’}}”8imagesrc=”../../res/image/wechat-logo.png”/image9text{{item.text}}/text10/view11viewwx:if=”{{item.orientation==’r’}}”12text{{item.text}}{{item.url}}/text13imagesrc=”{{userInfo.avatarUrl}}”/image14/view15/block16/view17/scroll-view18formbindsubmit=”sendChat”19view20inputplaceholder=””name=”ask_word”type=”text”bindconfirm=”sendChat”value=”{{askWord}}”/21buttonformType=”submit”size=”mini”发送/button22/view23/form24/view-网络请求方法:1//app.js23req:function(method,url,arg){4letdomian=’http://www.tuling123.com/’,data={‘key’:’9d2ff29d44b54e55acadbf5643569584′},dataType=’json’;//为方便广大群众,提供key5letheader={‘content-type’:’application/x-www-form-urlencoded’};67if(arg.data){8data=Object.assign(data,arg.data);9}10if(arg.header){11header=Object.assign(header,arg.header);12}13if(arg.dataType){14dataType=arg.dataType;15}1617letrequest={18method:method.toUpperCase(),19url:domian+url,20data:data,21dataType:dataType,22header:header,23success:function(resp){24console.log(‘responsecontent:’,resp.data);2526letdata=resp.data;2728typeofarg.success==”function”&&arg.success(data);29},30fail:function(){31wx.showToast({32title:’请求失败,请稍后再试’,33icon:’success’,34duration:200035});3637typeofarg.fail==”function”&&arg.fail();38},39complete:function(){40typeofarg.complete==”function”&&arg.complete();41}42};43wx.request(request);44}完!

赞(0) 打赏
未经允许不得转载:E企盈小程序开发-热线:4006-838-530 » 微信机器人免费版,微信小程序智能机器人
分享到: 更多 (0)
E企盈小程序直播营销卖货系统
E企盈直播平台营销卖货系统

评论 抢沙发

E企盈小程序开发

联系我们联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏