支付宝小程序和微信小程序之间的互相转换
1.首先是文件名
微信小程序 wxss ------ 支付宝小程序 acss
微信小程序 wxml ------ 支付宝小程序 axml
2.调用方法前缀
微信小程序 wx. ------ 支付宝小程序 my.
3.网络请求
3.1 返回的状态值
微信小程序
res.statusCode
支付宝小程序
res.status
3.2 header传参
微信小程序
header

支付宝小程序
headers

这一点特别需要注意!!!
4.指令、点击事件等
微信小程序
bindtap、bindinput、
(此处要注意大小写)
wx:if、wx:for
支付宝小程序
onTap、onInput
(此处要注意大小写)
a:if、a:for
5.showToast提示框
微信小程序 (如果不设置icon:none,会默认显示成功的图标)


支付宝小程序


6.获取缓存
微信小程序
wx.getStorageSync('score')
支付宝小程序
my
.getStorageSync({key: 'score'}).data
7.自定义组件的传值
微信小程序
properties: { showOrder: { type:Boolean, value: false }, value: { type: Array, value: [] }, },
支付宝小程序
props: { showOrder: false, value: [], styles: 'margin-top: 30rpx;' },
8.image组件
微信小程序:
没有默认显示图片属性
支付小程序:
default-source
9.组件生命周期
微信小程序:


支付宝小程序:


具体查看官方文档
10.设置标题
微信小程序:
navigationBarTitleText
支付宝小程序:
defaultTitle
11.获取登录凭证code
微信小程序:
wx.login 返回的code存在res.code中
支付宝小程序:
my.getAuthCode 返回的code存在res.authCode中
--------------------------------------------------------------2019.12.26
12.模态对话框
微信小程序:
wx.showModal({ title: '提示', content: '这是一个模态弹窗', cancelText: '取消按钮', confirmText: '确定按钮', success (res) { if (res.confirm) { console.log('用户点击确定') } else if (res.cancel) { console.log('用户点击取消') } } })
支付宝小程序
my.confirm({ title: '温馨提示', content: '您是否想查询快递单号:1234567890', confirmButtonText: '马上查询', cancelButtonText: '暂不需要', success: (result) => { my.alert({ title: `${result.confirm}`, }); }, });
注意:支付宝小程序的模态框,在点击确定按钮或者取消按钮后,事件都会进入success函数中;而微信小程序的模态框,在点击确定按钮才会进入success函数中,而点击取消按钮会进入fail函数中
13.app.json
微信小程序
"window": { "navigationBarTitleText": "速车挪车", "navigationBarTextStyle": "black", // 必须为black或white "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#000" }, "tabBar": { "color": "#999999", "selectedColor": "#108EE9", "list": [ { "pagePath": "pages/index/index", "iconPath": "images/tabBar1.png", "selectedIconPath": "images/tabBar2.png", "text": "首页" } ] },
支付宝小程序
"window": { "defaultTitle": "速车挪车", "titleBarColor": "#fff" }, "tabBar": { "textColor": "#999999", "selectedColor": "#108EE9", "items": [ { "pagePath": "pages/index/index", "icon": "images/tabBar1.png", "activeIcon": "images/tabBar2.png", "name": "首页" } ] },
14.input属性maxlength(举例)
微信小程序

支付宝小程序

15.支付
微信小程序
wx.requestPayment({ timeStamp: '', nonceStr: '', package: '', signType: 'MD5', paySign: '', success (res) { }, fail (res) { } }) 注:微信小程序的支付参数和支付宝的支付参数不同,且,支付成功进入success,支付失败进入fail
支付宝小程序
my.tradePay({ tradeNO: '', // 调用 小程序支付 时必填 orderStr: '', // 调用 资金授权 时必填 success (res) { }, fail (res) { }, complete (res) { }, }) 注: 支付成功或者失败都会进入success中,但是会返回不用的状态码,根据状态码来判断用户具体的支付成功或者失败的操作
未完。。。。待续。。。