• 微信小程序知识云开发


    一个小程序最多5个服务类目,一个月可以修改3次类目

    小程序侵权投诉的发起与应对

    软件著作权作品登记证书

    实现小程序支付功能

    如何借助官方支付api简单、高效率地实现小程序支付功能

    借助小程序云开发实现
    只需要一个简单的云函数

    实现微信小程序支付功能

    exports.main = async(event, context) => {
     const wxContent = cloud.getWXContext()
     let {
      orderid,
      money
     } = event; 
     // 初始化支付
     const api = tenpay.init(config);
     let result = await api.getPayParams({
      out_trade_no: orderid,
      body: '商品简单描述',
      total_fee: money, // 订单金额
      openid: wxContext.OPENID // 付款用户的openid
     });
      return result;
    }
    

    小程序界面设计、交互、功能与他人的手机应用软件或在先发布的小程序构成实质性相似,构成小程序抄袭

    微信小程序代码抄袭,侵犯他人软件著作权

    <image mode="widthFix" src="../../img/next-course.png"></image>
    
    image {
      100%;
    }
    
    <view class="card">
     <image src="" mode="widthFix"></image>
    </view>
    
    .card image {
     
    }
    .card {
     margin: 10rpx;
    }
    .bg {
      100%;
    }
    

    什么是UniApp

    Union Application
    前端框架
    基于Vue.js
    开发规范同小程序

    <style>
     @import url("index.css");
    </style>
    

    widthFix
    宽度不变,高度自动变化,保存原图宽高比不变

    一个云开发小程序
    // app.js

    App({
     onLaunch: function() {
      wx.cloud.init({
       env: "prod-ayrkn"
      })
     }
    })
    

    创建云函数pay

    引入三方依赖tenpay

    在命令行里执行 npm i tenpay

    [外链图片转存失败(img-Ag8oCRF9-1565915745539)(https://upload-images.jianshu.io/upload_images/11158618-4cd8f7865c386211.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)]

    [外链图片转存失败(img-oVV41MNS-1565915745543)(https://upload-images.jianshu.io/upload_images/11158618-ac663878f28c218b.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)]

    [外链图片转存失败(img-d6mAyp0R-1565915745544)(https://upload-images.jianshu.io/upload_images/11158618-b1a8579796ebb099.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)]

    //云开发实现支付
    const cloud = require('wx-server-sdk')
    cloud.init()
    
    //1,引入支付的三方依赖
    const tenpay = require('tenpay');
    //2,配置支付信息
    const config = {
    appid: '你的小程序appid', 
    mchid: '你的微信商户号',
    partnerKey: '微信支付安全密钥', 
    notify_url: '支付回调网址,这里可以先随意填一个网址', 
    spbill_create_ip: '127.0.0.1' //这里填这个就可以
    };
    
    exports.main = async(event, context) => {
    const wxContext = cloud.getWXContext()
    let {
    orderid,
    money
    } = event;
    //3,初始化支付
    const api = tenpay.init(config);
    
    let result = await api.getPayParams({
    out_trade_no: orderid,
    body: '商品简单描述',
    total_fee: money, //订单金额(分),
    openid: wxContext.OPENID //付款用户的openid
    });
    return result;
    }
    

    [外链图片转存失败(img-2ZPAhgPT-1565915745547)(https://upload-images.jianshu.io/upload_images/11158618-30dac116851543dd.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)]

    提交页面,调用pay云函数

    <form bindsubmit="formSubmit" bindreset="formReset">
     <input name="orderid" placeholder="随便写一个订单号"/>
     <input name="money" placeholder="随便写一个订购单总价"/>
     <button form-type="submit" type="primary">提交订单</button>
    </form>
    

    订单号要大于6位
    wx.requestPayment(Object object)
    发起微信支付

    [外链图片转存失败(img-tlXXELCg-1565915745554)(https://upload-images.jianshu.io/upload_images/11158618-fb56af8490ecee9e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)]

    调用wx.requestPayment实现支付

    wx.requestPayment({
     timeStamp: '',
     nonceStr: '',
     package: '',
     signType: 'MD5',
     paySign: '',
     success(res){},
     fail(res){}
    })
    

    pay.js

    // pages/pay/pay.js
    Page({
    //提交订单
    formSubmit: function(e) {
    let that = this;
    let formData = e.detail.value
    console.log('form发生了submit事件,携带数据为:', formData)
    wx.cloud.callFunction({
    name: "pay",
    data: {
    orderid: "" + formData.orderid,
    money: formData.money
    },
    success(res) {
    console.log("提交成功", res.result)
    that.pay(res.result)
    },
    fail(res) {
    console.log("提交失败", res)
    }
    })
    },
    //实现小程序支付
    pay(payData) {
    //官方标准的支付方法
    wx.requestPayment({
    timeStamp: payData.timeStamp,
    nonceStr: payData.nonceStr,
    package: payData.package, //统一下单接口返回的 prepay_id 格式如:prepay_id=***
    signType: 'MD5',
    paySign: payData.paySign, //签名
    success(res) {
    console.log("支付成功", res)
    },
    fail(res) {
    console.log("支付失败", res)
    },
    complete(res) {
    console.log("支付完成", res)
    }
    })
    }
    })
    

    [外链图片转存失败(img-gE4DbneD-1565915745555)(https://upload-images.jianshu.io/upload_images/11158618-df345792390c4d22.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)]

    [外链图片转存失败(img-TytLDHMo-1565915745557)(https://upload-images.jianshu.io/upload_images/11158618-55501c01b2975818.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)]

    [外链图片转存失败(img-GRThAPsZ-1565915745562)(https://upload-images.jianshu.io/upload_images/11158618-a28a9b0bda6c5b7e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)]


    若本号内容有做得不到位的地方(比如:涉及版权或其他问题),请及时联系我们进行整改即可,会在第一时间进行处理。


    请点赞!因为你们的赞同/鼓励是我写作的最大动力!

    欢迎关注达叔小生的简书!

    这是一个有质量,有态度的博客

    [外链图片转存失败(img-MuN0jPRW-1565915745564)(https://upload-images.jianshu.io/upload_images/11158618-9ab0d3fef85d80ce?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)]

    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 3.0 许可协议。转载请注明出处!
  • 相关阅读:
    内存管理简介之Buddy算法和slab分配
    进程通信方式介绍
    Linux内核网络栈实现分析(十一)驱动程序层(下)
    Linux内核网络协议栈深入分析(二)sk_buff的操作函数
    Linux内核网络协议栈深入分析(一)与sk_buff有关的几个重要的数据结构
    内核源码学习:伙伴算法
    寒假Day16Dinic模板更新+优化
    寒假Day20:数位dp
    寒假Day21:Catalan Square卡特兰数 JAVA写大数
    寒假Day17UVALive3231Fair Share(最大流+二分)
  • 原文地址:https://www.cnblogs.com/dashucoding/p/11932325.html
Copyright © 2020-2023  润新知