|
|
微擎相关文档:https://wiki.w7.cc/document/35/1032
微信官网相关文档:https://developers.weixin.qq.com ... est/wx.request.html
小程序通过app.util.request向服务端发起请求,在wxapp.php里面的方法处理好数据后,服务端通过return $this->result($errno, $message, $data);返回结果给小程序;
小程序端wxml文件:
- <button class="weui-btn weui-btn_primary" bindtap="send">发布文字</button>
复制代码
小程序端js文件:
- send:function(){
- app.util.request({
- 'url': 'entry/wxapp/ceshi',
- 'data': {
- name: '小明',
- age: '18'
- },
- 'cachetime': '30',
- success(res) {
- console.log(res);
- }
- })
- },
复制代码
服务器端wxapp.php
- public function doPageceshi(){
- global $_GPC, $_W;
- $errno = 0;
- $message = '记录成功';
- $data = array('msg' => '发布成功');
- $datas=['name'=>$_GPC['name'],'age'=>$_GPC['age']];
- //载入日志函数
- load()->func('logging');
- //记录文本日志
- logging_run($datas);
- return $this->result($errno, $message, $data);
- }
复制代码
|
|