- 地图markers图标不显示和缩放偏移的问题
1、问题 今天踩了个坑,markers在设置iconPath后,出现了两个问题: 1)开发工具上正常显示的图标,真机上却不知道跑哪去了。 2)拖拽后找到了图标,但真机上放大缩小地图,自定义图标会产生非常明显的偏移。 2、方案 后来经过多次测试,设置anchor: {x: 0.5,y: 0.5}可以解决问题,x、y的偏移值一定都要用0.5。 3、分析 真机地图初始化和缩放的时候markers的自定义图标在计算时有问题,从实际效果中很明显可以看得出,计算被anchor图标锚点配置影响,但从anchor的定义来看是不应该影响图标计算的,显然是底层计算没处理好。
2018-07-03 - 小程序整个支付流程接口(包含后台chuanshu乱码的处理)
1,获取:openid接口; ,2,完成整套支付流程接口 // 用code换取openId openIdUrl: `https://developers.weixin.qq.com/`, getOpenId: function (code) { var that = this; wx.request({ url: openIdUrl+"openid", data: { code: code }, method: 'GET', success: function (res) { console.log('返回openId') console.log(res.data) that.generateOrder(res.data.openid) }, fail: function () { // fail }, complete: function () { // complete } }) }, // 生成支付订单的接口 paymentUrl: openIdUrl+`payment`, /**生成商户订单 */ generateOrder: function (openid) { var that = this //统一支付 wx.request({ url: openIdUrl+'wxpay', method: 'GET', data: { openid: openid, total_fee: '5', // body: '支付测试', // attach: '真假酒水' body: 'zhifuceshi', attach: 'zhenjiajiushui' }, success: function (res) { console.log(res) var pay = res.data //发起支付 var timeStamp = pay[0].timeStamp; console.log("timeStamp:" + timeStamp) var packages = pay[0].package; console.log("package:" + packages) var paySign = pay[0].paySign; console.log("paySign:" + paySign) var nonceStr = pay[0].nonceStr; console.log("nonceStr:" + nonceStr) var param = { "timeStamp": timeStamp, "package": packages, "paySign": paySign, "signType": "MD5", "nonceStr": nonceStr }; that.pay(param) }, }) }, 注:中文乱码,tomcat 容器,配置 /* 支付 */ pay: function (param) { console.log("支付") console.log(param) wx.requestPayment({ timeStamp: param.timeStamp, nonceStr: param.nonceStr, package: param.package, signType: param.signType, paySign: param.paySign, success: function (res) { // success console.log("支付") console.log(res) wx.navigateBack({ delta: 1, // 回退前 delta(默认为1) 页面 success: function (res) { wx.showToast({ title: '支付成功', icon: 'success', duration: 2000 }) }, fail: function () { // fail }, complete: function () { // complete } }) }, fail: function (res) { // fail console.log("支付失败") console.log(res) }, complete: function () { // complete console.log("pay complete") } }) } 成功跳转版 // pages/pay/pay.js var app = getApp(); var openid; Page({ data: {}, onLoad: function (options) { // 页面初始化 options为页面跳转所带来的参数 }, /* 微信支付 */ wxpay: function () { var that = this //登陆获取code wx.login({ success: function (res) { console.log(res.code) //获取openid that.getOpenId(res.code) } }); }, getOpenId: function (code) { var that = this; wx.request({ url:openIdUrl+ "openid", data: { code: code }, success: function (res) { console.log('返回openId') console.log(res.data) that.generateOrder(res.data) }, fail: function () { // fail }, complete: function () { // complete } }) }, /**生成商户订单 */ generateOrder: function (openid) { var that = this //统一支付 wx.request({ url: openIdUrl+'wxpay', method: 'GET', data: { openid: openid, total_fee: '1', body: '50套亲测小程序源码', attach: '行业源码' }, success: function (res) { console.log(res) var pay = res.data //发起支付 var timeStamp = pay[0].timeStamp; console.log("timeStamp:" + timeStamp) var packages = pay[0].package; console.log("package:" + packages) var paySign = pay[0].paySign; console.log("paySign:" + paySign) var nonceStr = pay[0].nonceStr; console.log("nonceStr:" + nonceStr) var param = { "timeStamp": timeStamp, "package": packages, "paySign": paySign, "signType": "MD5", "nonceStr": nonceStr }; that.pay(param) }, }) }, /* 支付 */ pay: function (param) { console.log("支付") console.log(param) wx.requestPayment({ timeStamp: param.timeStamp, nonceStr: param.nonceStr, package: param.package, signType: param.signType, paySign: param.paySign, success: function (res) { // success //付款成功,这里可以写你的业务代码 console.log("支付") console.log(res) // 写入订单号,更新订单状态 // 下单成功,跳转到订单管理界面 wx.redirectTo({ url: "/pages/order-list/index" }); wx.navigateBack({ delta: 1, // 回退前 delta(默认为1) 页面 success: function (res) { wx.showToast({ title: '支付成功', icon: 'success', duration: 2000 }); }, fail: function () { // fail }, complete: function () { // complete } }) }, fail: function (res) { // fail console.log("支付失败") console.log(res) }, complete: function () { // complete console.log("pay complete") } }) } })
2018-07-03