- 为什么导航的地图位置与真实的位置差很多?
// index.js const app = getApp() const DB= wx.cloud.database() Page({ data: { latitude: 35.2457853400, //初始化 longitude: 113.2484514100, }, onLoad: function (options) { var dname = options.dname; console.log('测试',dname) var labelname=dname DB.collection('map').where({ label:{"content":labelname} }) .get() .then(res=>{ console.log(res); console.log("test 测试1",res.data) console.log("test 测试1",res.data[0].latitude) console.log("test 测试1",res.data[0].longitude) var latitude=res.data[0].latitude var latitude=parseInt(latitude) var longitude=res.data[0].longitude var longitude=parseInt(longitude) var name=res.data[0].label.content1 wx.openLocation({ latitude:(latitude), longitude: (longitude), name: (name), scale: 15 }) }) .catch(err=>{ console.log(err); }) } })
2020-07-09 - 按查询按升序排列,为什么提示错误?
const db = wx.cloud.database() db.collection('tt').orderby('time','asc').where({ //此地需要写orderby?? time: 20//可为变量 }) .get() .then(res => { console.log(res); }) 提示:VM212:1 thirdScriptError db.collection(...).orderby is not a function;at "pages/page/index" page lifeCycleMethod onLoad function TypeError: db.collection(...).orderby is not a function at Ue.onLoad (http://127.0.0.1:17063/appservice/pages/yd%20page/index.js:231:25) at Ue.<anonymous> (http://127.0.0.1:17063/appservice/__dev__/WAService.js:2:1928503) at Ue.p.__callPageLifeTime__ (http://127.0.0.1:17063/appservice/__dev__/WAService.js:2:1928248) at jt (http://127.0.0.1:17063/appservice/__dev__/WAService.js:2:1944068) at Mt (http://127.0.0.1:17063/appservice/__dev__/WAService.js:2:1946017) at Function.<anonymous> (http://127.0.0.1:17063/appservice/__dev__/WAService.js:2:1956428) at i.<anonymous> (http://127.0.0.1:17063/appservice/__dev__/WAService.js:2:1919155) at i.emit (http://127.0.0.1:17063/appservice/__dev__/WAService.js:2:621502) at Object.emit (http://127.0.0.1:17063/appservice/__dev__/WAService.js:2:588082) at i.<anonymous> (http://127.0.0.1:17063/appservice/__dev__/WAService.js:2:679270)
2020-07-09 - 在电脑上运行可以,在手机上运行不显示二维码?
1、pages/index/index.js const app = getApp() var access_token var accessToken }) Page({ onLoad: function () { var that = this; var dname=123456 wx.request({ url: 'https://api.weixin.qq.com/cgi-bin/token', header: { 'content-type': 'application/json' }, data: { grant_type: 'client_credential', appid:'xxxxxxxxxxxxxx', secret: 'xxxxxxxxxxxxxxxxx' }, success(res) { accessToken = res.data.access_token wx.request({ url: 'https://api.weixin.qq.com/wxa/getwxacode?access_token='+accessToken, method: 'POST', responseType: 'arraybuffer', data: { "path": 'pages/index2/index?dname='+dname, "width": 430, }, success(res) { let base64 = wx.arrayBufferToBase64(res.data) //console.log(base64) let codeImg= 'data:image/PNG;base64,' + base64 console.log(codeImg) that.setData({codeImg: codeImg}) }, }) } }) }, }) 2、pages/index/index.wxml <view class="m"> <image style="width: 200px; height: 200px; background-color: #eeeeee;" src="{{codeImg}}"></image> </view> 3、pages/index2/index.js const DB= wx.cloud.database() const db= wx.cloud.database() Page({ onLoad: function (options) { var dname=options.dname this.setData({ dname:dname }) DB.collection("sok").add({ // 添加数据到 data: { dname:dname } }) }, 4、pages/index2/index.wxml <text>{{pdname2}}</text> ------------------------------------------------------------------------ 在电脑上运行可以,在手机上运行不显示二维码?
2020-07-08 - openid返回值是什么?是null吗?
问题已解决,是用户名获取不到 ------------------------------------------------------------------------------------------------- 为什么头像拒绝读取的用户,依然可以跳转到下一页log呢?
2020-07-06 - openId,不让获取头像时,返回值 是null?
openId,不让获取头像时,返回值 是null?,应该不是,以null写的判断不起效
2020-07-06 - 提示:页面不存在?
1、ewm云函数 const cloud = require('wx-server-sdk') cloud.init({ env: 'xxxxxxxx' }) exports.main = async (event, context) => { try { const result = await cloud.openapi.wxacode.createQRCode({ path:event.urlname, //未验证 width: 410 }) const file = await cloud.uploadFile({ cloudPath: 'img.jpg', fileContent: result.buffer, }) return file } catch (err) { return err } } 2、index.js 调用代码 console.log('测试',dname) wx.cloud.callFunction({ //扫码传递参数pdname2(编号) name: "ewm", data: { urlname: '../tt index/index?dname=' + dname }, success: res =>{ console.log('test1',res.result) this.setData({ ima:res.result.fileID }) }, fail: err =>{ console.log() } }) 3、index.wmsl <view class="wm1"> <image style="width: 200px; height: 200px; background-color: #eeeeee;" src="{{ima}}"></image> </view> ------------------------------------------------------------------------------------------------- 另,有pages/tt index/index能访问。 扫码后,提示:页面不存在
2020-07-03 - 自定义tabbar 在电脑上运行正常,但真机调试时,出现错误?
1.新建template文件夹用于保存tabBar模板,template/template.wxml<template name="tabBar"> <view class="tabBar"> <block wx:for="{{tabBar}}" wx:for-item="item" wx:key="tabBar"> <view class="tabBar-item"> <navigator open-type="reLaunch" url="{{item.pagePath}}"> <view><image class="icon" src='{{item.iconPath}}'></image></view> <view class="{{item.current== 1 ? 'tabBartext' :''}}">{{item.text}}</view> </navigator> </view> </block> </view> </template> 2.创建template.wxss.icon{ width:54rpx; height: 54rpx; } .tabBar{ width:100%; position: fixed; bottom:0; padding:10rpx; margin-left:-4rpx; background:#F7F7FA; font-size:24rpx; color:#8A8A8A; box-shadow: 3rpx 3rpx 3rpx 3rpx #aaa; z-index: 9999; } .tabBar-item{ float:left; width:20%; text-align: center; overflow: hidden; } /*当前字体颜色*/ .tabBartext{ color:red; } .navigator-hover{ background-color: rgba(0, 0, 0, 0); } 3.创建template.js,初始化数据//初始化数据 function tabbarinit() { return [ { "current": 0, "pagePath": "/pages/dashboard/index", "iconPath": "/images/goback.png", "text": "返回商城" }, { "current": 0, "pagePath": "/pages/collage/index", "iconPath": "/images/collage1.png", "selectedIconPath": "/images/collage.png", "text": "拼团首页" }, { "current": 0, "selectedIconPath": "/images/list.png", "iconPath": "/images/list1.png", "pagePath": "/pages/collage-list/index", "text": "活动列表" }, { "current": 0, "selectedIconPath": "/images/collage-order.png", "iconPath": "/images/collage-order1.png", "pagePath": "/pages/collage-order/index", "text": "我的订单" }, { "current": 0, "selectedIconPath": "/images/group.png", "iconPath": "/images/group1.png", "pagePath": "/pages/group/index", "text": "我的团" } ] } //tabbar 主入口 function tabbarmain(bindName = "tabdata", id, target) { var that = target; var bindData = {}; var otabbar = tabbarinit(); otabbar[id]['iconPath'] = otabbar[id]['selectedIconPath']//换当前的icon otabbar[id]['current'] = 1; bindData[bindName] = otabbar that.setData({ bindData }); } module.exports = { tabbar: tabbarmain } 4.使用方法先把样式文件载入app.wxss@import "/template/template.wxss"; 新建一个页面,比如index.wxml,引入模板<import src="../../template/template.wxml"/> <template is="tabBar" data="{{tabBar:bindData.tabBar}}"/> index.js 初始化数据var template = require('../../template/template.js'); Page({ onLoad: function () { template.tabbar("tabBar", 0, this)//0表示第一个tabbar }, }) 其它新建页面也跟index.wxml一样,初始化数据。-------------------------------------------------------------------------------------------------------------------------------------------- 在电脑上运行正常,但真机调试时,出现错误: Error: module "template/template.js" is not defined
2020-07-02 - 与服务器通信,写入mysql数据库数据,写入不成功?
一、微信小程序 1、index.js const app = getApp() Page({ fortn: function () { //写入数据库 wx.request({ url: 'http://xxxxxxxxx/post.php', method: 'GET', data: { something1: '李四', something2: '25', something3: '0' }, header: { 'content-Type': 'application/x-www-form-urlencoded' }, success(res) { console.log(res.data); if (res.data.status == 0) { wx.showToast({ title: '提交失败!!!', icon: 'loading', duration: 1500 }) } else { wx.showToast({ title: '提交成功!!!', icon: 'success', duration: 1000 }) } } }); }, }) 2、index.wxml <button class="ff" bindtap='fortn' >增加</button> -------------------------------------------------------------- 二、服务器端 1、connect.php <?php //header("Content-type: text/html; charset=utf8"); //1. 声明字符编码 $host='127.0.0.1';//数据库ip $user='root';//用户名 $password='123456';//密码 $dbName='mymy';//要连接的数据库名 $con =new mysqli($host,$user,$password,$dbName,3308);//数据库连接 /*if ($con->connect_error) { echo "系统异常,连接数据库失败"; } else { echo "连接成功"; }*/ ?> 2、post.php <?php //header("Content-type: text/html; charset=utf8"); include 'connect.php';//调用connect.php文件 $something1=$_GET['something1'];//'小明';// $something2=$_GET['something2'];//'16';// $something3=$_GET['something3'];//'0';// if ($con->connect_error) { die("连接失败:".$con->connect_error); } else { $sql="INSERT INTO `doctor`(`name`, `age`, `xb`) VALUES ('$something1','$something2','$something3');"; $res=$con->query($sql); if($res){ $arr['status'] = 1; $arr['info'] = 'success'; }else{ $arr['status'] = 0; $arr['info'] = 'error'; } echo json_encode($arr); die; } ?> --------------------------------------------------- 三、mysql数据库名称为:mymy,表单是doctor,字段名称为`name`, `age`, `xb` ----------------------------------------------------------------------------- 增加数据不成功,不知为什么?(服务器http服务能访问到)
2020-06-28 - 云函数调用支付,怎样让支付窗口倒计时?
1、函数paypay const cloud = require('wx-server-sdk') cloud.init({ env: 'xxxxxxxx' }) exports.main = async (event, context) => { const res = await cloud.cloudPay.unifiedOrder({ "body" : "小秋TIT店-超市22", "outTradeNo" :event.outTradeNo, "spbillCreateIp" : "127.0.0.1", "subMchId" : "xxxxxxx", "totalFee" :event.totalFee, "envId": "xxxxxxxxx", "functionName": "pay", "nonceStr": event.nonceStr }) return res } 2、index.js Page({ onchick:function(){ var code=dkjfdkfjkdj var codestr=kdjfkdjfkjdflkjdfkjdfkj wx.cloud.callFunction({ name: 'paypay', data: { totalFee:5, outTradeNo:code, nonceStr: codestr }, success: res => { const payment = res.result.payment wx.requestPayment({ ...payment , success (res) { console.log('pay success', res) }, fail (res) { console.error('pay fail_1', err) } }) }, fail:console.log('pay fail_2'), }) } }) 3、index.wxml <button class="mf" ' bindtap='onchick'>支付</button> ------------------------------------------------------------------------------------------ 云函数调用支付成功,但怎样让支付浮窗倒计时呀?长时间不支付时,需要让浮窗消失,退出支付。
2020-06-27 - 为什么上传云函数会报错?
Error:更新云函数失败
2020-06-14