• 支付成功后给指定人员发送微信公众号消息


    支付成功后给指定人员(导购)发送微信公众号消息
    微信openid已录入数据库表
    调用后台接口发送消息接口调用代码如下:

    	  //----add by grj 20231017 start 
    	  //订单支付成功发送微信公众号消息
    	  $.ajax({
    	     url:'http://www.menggu100.com:7077/strutsJspAjax/SendWechatMessageAction?orderNo='+state.orderId,
    	     type:"POST",
    	     data:{},
    	     success(data){
    	       console.log("请求成功");
    	       console.log(data);
    	     },
    	     error(err){
    	       console.log(err);
    	       console.log("请求失败");
    	     },
    	     complete(){
    	       console.log("请求完成");
    	     }
    	   })
    	   //----add by grj 20231017 end 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19

    整个页面如下
    fa-uniapp-3.0.1\pages\pay\result.vue

    
    <template>
      <s-layout title="支付结果" :bgStyle="{ color: '#FFF' }">
        <view class="pay-result-box ss-flex-col ss-row-center ss-col-center">
          <view class="pay-waiting ss-m-b-30" v-if="payResult === 'waiting'"> view>
          <image
            class="pay-img ss-m-b-30"
            v-if="payResult === 'success'"
            :src="sheep.$url.static('/assets/addons/shopro/uniapp/order/order_pay_success.gif')"
          >image>
          <image
            class="pay-img ss-m-b-30"
            v-if="['failed', 'closed'].includes(payResult)"
            :src="sheep.$url.static('/assets/addons/shopro/uniapp/order/order_paty_fail.gif')"
          >image>
          <view class="tip-text ss-m-b-30" v-if="payResult == 'success'">{{
            state.orderInfo.pay_mode === 'offline' ? '下单成功' : '支付成功'
          }}
    	  view>
          <view class="tip-text ss-m-b-30" v-if="payResult == 'failed'">支付失败view>
          <view class="tip-text ss-m-b-30" v-if="payResult == 'closed'">该订单已关闭view>
          <view class="tip-text ss-m-b-30" v-if="payResult == 'waiting'">检测支付结果...view>
          <view class="pay-total-num ss-flex" v-if="payResult === 'success'">
            <view v-if="Number(state.orderInfo.pay_fee) > 0">¥{{ state.orderInfo.pay_fee }}view>
            <view v-if="state.orderInfo.score_amount && Number(state.orderInfo.pay_fee) > 0">+view>
            <view class="price-text ss-flex ss-col-center" v-if="state.orderInfo.score_amount">
              <image
                :src="sheep.$url.static('/assets/addons/shopro/uniapp/goods/score1.svg')"
                class="score-img"
              >image>
              <view>{{ state.orderInfo.score_amount }}view>
            view>
          view>
          <view class="btn-box ss-flex ss-row-center ss-m-t-50">
            <button class="back-btn ss-reset-button" @tap="sheep.$router.go('/pages/index/index')">
              返回首页
            button>
            <button
              class="check-btn ss-reset-button"
              v-if="payResult === 'failed'"
              @tap="sheep.$router.redirect('/pages/pay/index', { orderSN: state.orderId })"
            >
              重新支付
            button>
            <button
              class="check-btn ss-reset-button"
              v-if="payResult === 'success'"
              @tap="onOrder"
            >
              查看订单
            button>
            <button
              class="check-btn ss-reset-button"
              v-if="
                payResult === 'success' &&
                ['groupon', 'groupon_ladder'].includes(state.orderInfo.activity_type)
              "
              @tap="sheep.$router.redirect('/pages/activity/groupon/order')"
            >
              我的拼团
            button>
          view>
          
          <view class="subscribe-box ss-flex ss-m-t-44">
            <image
              class="subscribe-img"
              :src="sheep.$url.static('/assets/addons/shopro/uniapp/order/cargo.png')"
            >image>
            <view class="subscribe-title ss-m-r-48 ss-m-l-16">获取实时发货信息与订单状态view>
            <view class="subscribe-start" @tap="subscribeMessage">立即订阅view>
          view>
          
        view>
      s-layout>
    template>
    
    <script setup>
      import { onLoad, onHide, onShow } from '@dcloudio/uni-app';
      import { reactive, computed } from 'vue';
      import { isEmpty } from 'lodash';
      import sheep from '@/sheep';
      import $ from 'jquery'
    
      const state = reactive({
        orderId: 0,
        orderType: 'goods',
        result: 'unpaid', // 支付状态
        orderInfo: {}, // 订单详情
        counter: 0, // 获取结果次数
      });
    
      const payResult = computed(() => {
        if (state.result === 'unpaid') {
          return 'waiting';
        }
        if (state.result === 'paid') {
    	  //----add by grj 20231017 start 
    	  //订单支付成功发送微信公众号消息
    	  $.ajax({
    	     url:'http://www.menggu100.com:7077/strutsJspAjax/SendWechatMessageAction?orderNo='+state.orderId,
    	     type:"POST",
    	     data:{},
    	     success(data){
    	       console.log("请求成功");
    	       console.log(data);
    	     },
    	     error(err){
    	       console.log(err);
    	       console.log("请求失败");
    	     },
    	     complete(){
    	       console.log("请求完成");
    	     }
    	   })
    	   //----add by grj 20231017 end 
          return 'success';
        }
        if (state.result === 'failed') {
          return 'failed';
        }
    
        if (state.result === 'closed') {
          return 'closed';
        }
      });
    
      async function getOrderInfo(orderId) {
        let checkPayResult;
        state.counter++;
        if (state.orderType === 'recharge') {
          checkPayResult = sheep.$api.trade.order;
        } else {
          checkPayResult = sheep.$api.order.detail;
        }
        const { data, code } = await checkPayResult(orderId);
        if (code === 1) {
          state.orderInfo = data;
          if (state.orderInfo.status === 'closed') {
            state.result = 'closed';
            return;
          }
          if (state.orderInfo.status !== 'unpaid') {
            state.result = 'paid';
            // #ifdef MP
            subscribeMessage();
            // #endif
            return;
          }
        }
        if (state.counter < 3 && state.result === 'unpaid') {
          setTimeout(() => {
            getOrderInfo(orderId);
          }, 1500);
        }
        // 超过三次检测才判断为支付失败
        if (state.counter >= 3) {
          state.result = 'failed';
        }
      }
    
      function onOrder() {
        if(state.orderType === 'recharge') {
          sheep.$router.redirect('/pages/pay/recharge-log');
        }else {
          sheep.$router.redirect('/pages/order/list');
        }
      }
    
      // #ifdef MP
      function subscribeMessage() {
        let event = ['order_dispatched'];
        if (['groupon', 'groupon_ladder'].includes(state.orderInfo.activity_type)) {
          event.push('groupon_finish');
          event.push('groupon_fail');
        }
        sheep.$platform.useProvider('wechat').subscribeMessage(event);
      }
      // #endif
    
      onLoad(async (options) => {
        let id = '';
        // 支付订单号
        if (options.orderSN) {
          id = options.orderSN;
        }
        if (options.id) {
          id = options.id;
        }
        state.orderId = id;
    
        if (options.orderType === 'recharge') {
          state.orderType = 'recharge';
        }
    
        // 支付结果传值过来是失败,则直接显示失败界面
        if (options.payState === 'fail') {
          state.result = 'failed';
        } else {
          // 轮询三次检测订单支付结果
          getOrderInfo(state.orderId);
        }
      });
    
      onShow(() => {
        if(isEmpty(state.orderInfo)) return;
        getOrderInfo(state.orderId);
      })
    
      onHide(() => {
        state.result = 'unpaid';
        state.counter = 0;
      });
    script>
    
    <style lang="scss" scoped>
      @keyframes rotation {
        0% {
          transform: rotate(0deg);
        }
        100% {
          transform: rotate(360deg);
        }
      }
      .score-img {
        width: 36rpx;
        height: 36rpx;
        margin: 0 4rpx;
      }
    
      .pay-result-box {
        padding: 60rpx 0;
        .pay-waiting {
          margin-top: 20rpx;
          width: 60rpx;
          height: 60rpx;
          border: 10rpx solid rgb(233, 231, 231);
          border-bottom-color: rgb(204, 204, 204);
          border-radius: 50%;
          display: inline-block;
          // -webkit-animation: rotation 1s linear infinite;
          animation: rotation 1s linear infinite;
        }
        .pay-img {
          width: 130rpx;
          height: 130rpx;
        }
    
        .tip-text {
          font-size: 30rpx;
          font-weight: bold;
          color: #333333;
        }
    
        .pay-total-num {
          font-size: 36rpx;
          font-weight: 500;
          color: #333333;
          font-family: OPPOSANS;
        }
        .btn-box {
          width: 100%;
          .back-btn {
            width: 190rpx;
            height: 70rpx;
            font-size: 28rpx;
            border: 2rpx solid #dfdfdf;
            border-radius: 35rpx;
            font-weight: 400;
            color: #595959;
          }
          .check-btn {
            width: 190rpx;
            height: 70rpx;
            font-size: 28rpx;
            border: 2rpx solid #dfdfdf;
            border-radius: 35rpx;
            font-weight: 400;
            color: #595959;
            margin-left: 32rpx;
          }
        }
        .subscribe-box {
          .subscribe-img {
            width: 44rpx;
            height: 44rpx;
          }
          .subscribe-title {
            font-weight: 500;
            font-size: 32rpx;
            line-height: 36rpx;
            color: #434343;
          }
          .subscribe-start {
            color: var(--ui-BG-Main);
            font-weight: 700;
            font-size: 32rpx;
            line-height: 36rpx;
          }
        }
      }
    style>
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146
    • 147
    • 148
    • 149
    • 150
    • 151
    • 152
    • 153
    • 154
    • 155
    • 156
    • 157
    • 158
    • 159
    • 160
    • 161
    • 162
    • 163
    • 164
    • 165
    • 166
    • 167
    • 168
    • 169
    • 170
    • 171
    • 172
    • 173
    • 174
    • 175
    • 176
    • 177
    • 178
    • 179
    • 180
    • 181
    • 182
    • 183
    • 184
    • 185
    • 186
    • 187
    • 188
    • 189
    • 190
    • 191
    • 192
    • 193
    • 194
    • 195
    • 196
    • 197
    • 198
    • 199
    • 200
    • 201
    • 202
    • 203
    • 204
    • 205
    • 206
    • 207
    • 208
    • 209
    • 210
    • 211
    • 212
    • 213
    • 214
    • 215
    • 216
    • 217
    • 218
    • 219
    • 220
    • 221
    • 222
    • 223
    • 224
    • 225
    • 226
    • 227
    • 228
    • 229
    • 230
    • 231
    • 232
    • 233
    • 234
    • 235
    • 236
    • 237
    • 238
    • 239
    • 240
    • 241
    • 242
    • 243
    • 244
    • 245
    • 246
    • 247
    • 248
    • 249
    • 250
    • 251
    • 252
    • 253
    • 254
    • 255
    • 256
    • 257
    • 258
    • 259
    • 260
    • 261
    • 262
    • 263
    • 264
    • 265
    • 266
    • 267
    • 268
    • 269
    • 270
    • 271
    • 272
    • 273
    • 274
    • 275
    • 276
    • 277
    • 278
    • 279
    • 280
    • 281
    • 282
    • 283
    • 284
    • 285
    • 286
    • 287
    • 288
    • 289
    • 290
    • 291
    • 292
    • 293
    • 294
    • 295
    • 296
    • 297
    • 298
    • 299
    • 300
    • 301
    • 302
  • 相关阅读:
    redis安装(Windows和linux)
    ik分词器是什么,有那些配置? ik_smart和ik_max_word的两个分词算法有何区别?
    Java项目开发-基于Java的宠物领养管理系统(附源码)
    WebGL:使用着色器进行几何造型
    (附源码)spring boot大学毕业设计管理系统 毕业设计 030945
    用 Python 微调 ChatGPT (GPT-3.5 Turbo)
    Pinctrl 子系统简介
    C++ 语法基础课 习题4 —— 数组
    pcl--第四节 采样一致性算法RANSAC
    数字标牌/广告机无线组网方案
  • 原文地址:https://blog.csdn.net/guoruijun_2012_4/article/details/133901043