# WxappPlugin4SublimeText **Repository Path**: codercpf/WxappPlugin4SublimeText ## Basic Information - **Project Name**: WxappPlugin4SublimeText - **Description**: WxappPlugin4SublimeText - sublime_text的微信小程序开发插件,能自动提示和代码补全。非常不错哦 - **Primary Language**: JavaScript - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 6 - **Created**: 2017-09-13 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # WxappPlugin4SublimeText SublimeText的微信小程序的插件,能自动提示和代码补全。 ## 一、插件安装 将wxappPlugin目录拷贝到你的 ```html Data\Packages\User ``` 目录下即可使用 ## 二、如何使用 ### 1.生成js整个文件代码 在js文件中键入 ```html appjs---得到一个app.js格式文件 pagejs---得到一个page.js格式文件 ``` ### 2.js中的代码自动提示 比如数据请求,键入:wxrequest(或前几个字母,忽略大小写)回车后会自动出来: ```javascript // 请求服务器 wx.showLoading({ title: '加载中...', mask: true }); wx.request({ url: configGlobal.request_url + '/_WxaappApiServer/', method: 'GET', header: { 'Content-Type': 'application/json; charset=utf-8' }, data: { openId: app.globalData.openId, }, success: function(res) { wx.hideLoading(); console.log('服务器返回 success:', res); if (res.data.result == true) { var data = res.data.data; that.setData({ }); }else{ console.log('获取失败!'); wx.showToast({ title: '获取失败!', mask: true, duration: 2000 }); } }, fail: function(res) { console.log('request fail res:', res); }, complete: function(res) { wx.hideLoading(); } }); ``` 比如微信支付键入:wxrequestPayment(或前几个字母,忽略大小写)回车后会自动出来: ```javascript // 商品名称设置 var body = '这是测试商品'; var attach = '真假酒水'; var total_fee = '1'; // 请求服务器 wx.showLoading({ title: '加载中...', mask: true }); // 设置参数 var data_param = {}; data_param.openId = app.globalData.openId; data_param.body = body; data_param.attach = attach; data_param.total_fee = total_fee; var param = util.getRequestData(data_param); wx.request({ //必需 url: configGlobal.request_url + '/_WxaappApiServer/payGenerateOrder', method: 'GET', data: { openId: app.globalData.openId, body: body, attach: attach, total_fee: total_fee, }, header: { 'Content-Type': 'application/json; charset=utf-8' }, success: function(res) { wx.hideLoading(); console.log('服务器返回 success:', res); if (res.data.code == '0') { var data = res.data.data; console.log('data:', data); // 调用支付 wx.requestPayment({ 'timeStamp': data.timeStamp, 'nonceStr': data.nonceStr, 'package': data.package, 'signType': 'MD5', 'paySign': data.paySign, success: function(res) { console.log('success res:', res); if (res.errMsg == 'requestPayment:ok') { // 支付成功 that.setData({ }); wx.showToast({ title: "支付成功", icon: "success", //仅支持success或者loading duration: 2000, }); } else if (res.errMsg == 'requestPayment:fail cancel') { // 取消支付 wx.showToast({ title: "支付已被取消", icon: "success", //仅支持success或者loading duration: 2000, }); } else if (res.errMsg == 'requestPayment:fail') { // 支付失败 wx.showToast({ title: "支付失败", icon: "success", //仅支持success或者loading duration: 2000, }); } }, fail: function(res) { console.log('fail res:', res); // 支付失败 wx.showToast({ title: "支付失败", icon: "success", //仅支持success或者loading duration: 2000, }); }, complete: function(res) { // console.log('complete res:', res); } }); } else { wx.showToast({ title: "从服务器获取订单参数失败!", icon: "success", //仅支持success或者loading duration: 2000, }); } }, fail: function(res) { console.log('request fail res:', res); }, complete: function(res) { wx.hideLoading(); } }); ``` 比如:thatSetData ```javascript that.setData({ }); ``` 比如:consolelog ```javascript console.log('res:', res); ``` 比如:varthat ```javascript var that = this; ``` 比如:varsession(或前几个字母,忽略大小写)回车后会自动出来: ```javascript // 在需要得到用户信息的地方做下判断 var session = app.getSession(); if (!session) { app.getAuthorize(); } else { that.setData({ userInfo: app.globalData.userInfo }); } ``` 等等等等。。。。。。 ### 3.wxml文件中的提示 比如你在wxml中键入: ``` 比如你在wxml中键入: ``` 如果你选择后缀带_tip的,比如: ``` ## 三、目录结构 查看wxappDEMO中的例子,建议按其设定目录结构 # 备注 本插件如发现错误,或在使用的过程中若有困难,欢迎与我联系,我会及时修正。 ```html 制作:宿迁老葛 QQ:9411526 微信:sqgelin email: 9411526@qq.com ``` 注:加好友时请注明小程序字样。