1.1.3 • Published 10 months ago

subscribe-msg-mp v1.1.3

Weekly downloads
-
License
ISC
Repository
-
Last release
10 months ago

subscribe-msg-mp

International subscription message component.

Install

npm install subscribe-msg-mp --save

Usage

step 1:

Add the usingComponents configuration to the index.json file to import the subscribe-msg component:

{
  "usingComponents": {
    "subscribe-msg": "subscribe-msg-mp/es/index"
  }
}

step 2:

Call the subscribe-msg component in the index.axml file. The following sample code demonstrates the configuration to show the button and specifies whether to display the authorization panel according to the requestSubscribeMessage attribute:

<view>
  <view class="btn-container">
    <button onTap="onBtnTap">show</button>
  </view>
  <subscribe-msg requestSubscribeMessage={{requestSubscribeMessage}} appId="{{appId}}" authCode="{{authCode}}" templateIds={{templateIds}} onCallback="onHandleCallback" />
</view>

step 3:

In the index.js file, set the value of the requestSubscribeMessage attribute as true or false to display or hide the subscription panel. Pass in the handleCallback method and preset logic according to different subscription types (AGREE or REJECT).

Page({
  data: {
    appId: '${appId}',
    authCode: '${authCode}',
    templateIds: ${templateIds},
    requestSubscribeMessage: false,
  },
  onBtnTap() {
    this.setData({
      requestSubscribeMessage: true,
    });
  },

  handleCallback(res) {
    this.setData({
      requestSubscribeMessage: false,
    });
    if (res.success) {
      my.alert({
        title: res.type === 'AGREE' ? 'AGREE' : 'REJECT'
      });
    } else {
      my.alert({
        title: 'cancel'
      });
    }
  }
});

Attribute

namedescriptiontypedefault
requestSubscribeMessagerequest subscribe messageBooleanfalse
animationWhether to enable animationBooleantrue
authCodeString
templateIdsArray[]
onCallbackFunction
themecustom themeTheme{}

Interface

Theme

namedescriptiontype
colorTextPrimaryPrimary text colorString
colorTextSecondSecond text colorString
colorContentPrimaryPrimary content colorString
colorCheckboxCheckedCheckbox checked colorString
fontFamilyPrimaryPrimary font-familyString
borderRadiusButtonPrimaryPrimary Button border-radiusString
confirmButtonTypeConfirm Button typeString

Return value Description

success

  • indicates whether the subscription action is successful.
  • the user clicks Cancel to return false.(Click mask to cancel subscription process, and return errorCode)
  • The user clicks Reject to return true.(Click Reject actually performs the subscription process, but the submission type is unsubscribe, so it returns true).
  • Other exceptions also return false.

type

  • 'AGREE': Agree to subscribe.
  • 'REJECT': reject to subscribe.

errorCode

Codedescription
CANCELLEDUser cancelled
NETWORKNetwork error
SYSTEMSystem error
INCONSISTENT_TEMPLATE_TYPETemplates type must be same.
INVALID_TEMPLATE_CODEInvalid template code.
EXCEEDING_SUBSCRIPTION_LIMITTemplates count out of max bounds.
INCOMING_EXCEEDED_THE_UPPER_LIMITThe number of incoming templates exceeded the upper limit.
1.1.3

10 months ago

1.1.2

11 months ago

1.1.2-alpha.3

2 years ago

1.1.2-alpha.4

2 years ago

1.1.2-alpha.2

2 years ago

1.1.2-alpha

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago