当前位置: 首页 > 知识库问答 >
问题:

支付宝小程序 herculex 状态管理?

戴浩初
2025-04-14
  1. 如何更新全局变量?
  2. mapMutationsToMethod: ['loadUserInfo'] 如何使用
import { GlobalStore } from 'herculex';

export default new GlobalStore({
   state: {
      userInfo: {},
      offsetTop: 0,
      offsetBottom: 0,
      scrollHeight: 0,
   },
   plugins: [], //'logger'
   mutations: {
      updateSystemInfo(state, payload) {
         state = Object.assign(state, payload);
      },

      updateUserInfo(state, payload) {
         state.userInfo = payload;
      },
   },
   actions: {
      async loadSystemInfo({ commit }, payload) {
         commit('updateSystemInfo', payload);
      },

      async loadUserInfo({ commit }, payload) {
         commit('updateUserInfo', payload);
      },
   },
});
import SystemInfo from './utils/tools/getSystemInfo';
import GlobalStore from './utils/store/globalStore';

App(
   GlobalStore({
      async onLaunch(options) {
         const systemInfo = SystemInfo.execute();
         // 如果更新 systemInfo 到 $global
      },
   })
);

index.js

import SystemInfo from '../../utils/tools/getSystemInfo';
import store from '../../utils/store/sharedStore';

Page(
   store.register({
      mapMutationsToMethod: ['loadUserInfo'],
      async onLoad(options) {
         // 如何使用 loadUserInfo 
      },
   })
);

共有1个答案

养学
2025-04-14

App.js:

App(
  GlobalStore({
    async onLaunch(options) {
      const systemInfo = SystemInfo.execute();
      // 更新 systemInfo 到 $global
      this.$global.dispatch('loadSystemInfo', systemInfo);
    },
  })
);
Page(
  store.register({
    mapActionsToMethod: ['loadUserInfo'], 
    async onLoad(options) {
      
      const userInfo = { /* 用户信息 */ };
      this.loadUserInfo(userInfo);
      
      // this.$global.dispatch('loadUserInfo', userInfo);
    },
  })
);
Page(
  store.register({
    mapMutationsToMethod: ['updateUserInfo'],
    async onLoad(options) {
      const userInfo = { /* 用户信息 */ };
      this.updateUserInfo(userInfo);
    },
  })
);
 类似资料:
  • @megalo/target 的 platform 设置成 alipay,mini-css-extract-plugin 提取文件后缀改成支付宝小程序的 acss。 const createMegaloTarget = require( '@megalo/target' ) const compiler = require( '@megalo/template-compiler' ) const

  • 支付宝小程序 SDK 配置SDK安全域名 登录支付宝小程序管理后台,在「设置-开发设置-服务器域名白名单」中,增加诸葛域名: https://u.zhugeapi.net https://ubak.zhugeio.com 若是私有部署客户,服务器域名需要配置自己的域名。 安装SDK 安装SDK依赖npm install zg-sdk-ali --save-dev 引用SDK 1.在小程序项目的ap

  • 商家支付回调接口 url POST http://callback_url 回调参数说明 参数 类型 描述 uid string 百度用户ID order_id string 百度网盘订单号 third_order_id string 业务方订单号 pay_no string 支付流水号 pay_time int 支付时间 ts int 当前时间戳 sign string 签名参数(对以上参数按照

  • 同公众号支付

  • 说明 支付宝小程序支付交易SDK。 官方文档:https://opendocs.alipay.com/open/204/105465/ 类 请求参数类 APP支付参数 类名:\Yurun\PaySDK\AlipayApp\MiniApp\Params\Pay\Request 属性 名称 类型 说明 $method string 接口名称 $notify_url string 支付宝服务器主动通知商

  • 支付宝小程序 SDK 部署文档 1. 支付宝小程序后台为小程序添加合法域名: jice.fw4.me ac.jice.io 2. 引入 JS // 具体引入目录根据实际情况调整 import jice from './jice.min.js' 将下载的 SDK 文件放入对应的目录下,且在 app.js 中引入; 下载支付宝小程序 SDK(无框架版、支付宝小程序 SDK(框架版) 3. 初始化

  • 这种在支付宝小程序中的授权可以用代码删除吗?

  • 1、新版支付宝支付配置 配置支付宝支付之前,需要到支付宝商家中心开通手机网站应用和电脑网站应用两个产品。 产品开通链接:快捷手机wap支付 电脑网站支付 一个工作日即可通过审核,完成产品签约。 接下来,介绍支付宝支付配置教程。 第一步 登录商城后台,设置->交易设置->支付配置 ,选择支付宝支付,点击配置,进入到支付宝支付参数配置界面,选择新版支付宝。 需要我们配置应用APPID、应用私钥、应用公