leadlink_open_api 0.0.6 copy "leadlink_open_api: ^0.0.6" to clipboard
leadlink_open_api: ^0.0.6 copied to clipboard

discontinued
outdated

力联API开放接口

example/lib/main.dart

import 'dart:convert';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:leadlink_open_api/leadlink_open_api.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {


  @override
  void initState() {
    super.initState();
    initNow();
  }

  void initNow() async {
    final enbale = await LeadLinkOpenApi.init();
    debugPrint('应用是否可用: ' + enbale.toString());
  }


  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        appBar: AppBar(title: Text('接口测试样例'),backgroundColor: Colors.red),
        backgroundColor: Colors.black,
        body:Container(
          padding: EdgeInsets.all(20),
          child: GridView(
            gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
              crossAxisCount: 4,
              childAspectRatio: 4,
              mainAxisSpacing: 10,
              crossAxisSpacing: 10,
            ),
            children:testListView()),
        ),
        ),
      );
  }



  List<Widget> testListView() {
    
    
    return [

      // 生成加密串
      RaisedButton(
        hoverColor: Colors.blue,color: Colors.red,child: Text('生成加密串',style: TextStyle(color:Colors.white)),
        onPressed: () async {

        Map<String,dynamic> map = Map<String,dynamic>();
        map['li'] = 'MlkSG0YyzufV5r1tKrc1s0g1-gzGzoHsz';
        map['lk'] = 'ywe2IvlPvki7BeRnu5MbWJSp';
        // map['ls'] = 'https://api.uc.leadlink.fjlead.top';
        map['ls'] = 'https://leancloud.cn';
        map['pi'] = 'leadlink';
        map['pk'] = 'fjlead123456';
        map['ps'] = 'http://api.serverless.fjlead.top/parse/';
        // map['ai'] = 'b1820621-084e-42a6-9fcc-b23e14ddccd8';

        final e = APIUtil.encrypted(jsonEncode(map));
        debugPrint(e);

        final d = APIUtil.decrypted(e);
        Map<String,dynamic> m  = jsonDecode(d);
        debugPrint(m.toString());

      }),

      // 应用是否可用
      RaisedButton(
        hoverColor: Colors.blue,
        color: Colors.red,child: Text('初始化',style: TextStyle(color:Colors.white)),onPressed: () async {
        
        final d = await LeadLinkOpenApi.init();
        debugPrint('应用是否可用: ' + d.toString());

      }),

      // 解除密码
      RaisedButton(
        hoverColor: Colors.blue,
        color: Colors.red,child: Text('解开密码',style: TextStyle(color:Colors.white)),onPressed: () async {
        final salt = 'pwNLerWCDcHJQp9UNFG+mA==';
          var temp =  APIUtil.decrypted(salt);
          temp = temp.substring(4,temp.length);
          temp = temp.substring(0,temp.length -4);
          debugPrint(temp);
      }),

      // 批量解密
      RaisedButton(
        hoverColor: Colors.blue,
        color: Colors.red,child: Text('批量解密',style: TextStyle(color:Colors.white)),onPressed: () async {


        APIUser.getAllUserList(onFail: (msg)=>debugPrint(msg),onSucc: (list) {

            for(final item in list) {
              final salt = item.salt;
              var temp =  APIUtil.decrypted(salt);
              temp = temp.substring(4,temp.length);
              temp = temp.substring(0,temp.length -4);
              debugPrint(item.mobile + ',' + temp + ',' + item.nickName);
            }

          }
        );

        final salt = 'pwNLerWCDcHJQp9UNFG+mA==';
        var temp =  APIUtil.decrypted(salt);
        temp = temp.substring(4,temp.length);
        temp = temp.substring(0,temp.length -4);
        debugPrint(temp);

      }),



      // 获取短信验证码
      RaisedButton(
        hoverColor: Colors.blue,
        color: Colors.red,child: Text('获取短信验证码',style: TextStyle(color:Colors.white)),onPressed: () async{
        APIAccountManager.requestSMSCode('18046053193',onSucc: (msg){
          debugPrint(msg);
        },
        onFail: (msg){
          debugPrint(msg);
        });
      }),

      // 验证短信验证码
      RaisedButton(
        hoverColor: Colors.blue,
        color: Colors.red,child: Text('验证短信验证码',style: TextStyle(color:Colors.white)),onPressed: () async{
          APIAccountManager.verifyMobilePhone('18046053193','045923',onSucc: (msg){
            debugPrint(msg);
          },
          onFail: (msg){
            debugPrint(msg);
          });
      }),

      // 普通用户注册
      RaisedButton(
        hoverColor: Colors.blue,
        color: Colors.red,child: Text('普通用户注册',style: TextStyle(color:Colors.white)),onPressed: () async{

          APIAccountManager.signUp('18046053193','123456',nickName: '18046053193',onSucc: (msg){
            debugPrint(msg);
          },
          onFail: (msg){
            debugPrint(msg);
          });

      }),

      // 普通用户登录
      RaisedButton(
        hoverColor: Colors.blue,
        color: Colors.red,child: Text('普通用户登录',style: TextStyle(color:Colors.white)),onPressed: () async{
          APIAccountManager.login('18046053193','654321',onSucc: (msg,userId){
            debugPrint(msg);
            debugPrint('用户ID: ' + userId.toString());
          },
          onFail: (msg){
            debugPrint(msg);
          });
      }),

      // 管理员用户登录
      RaisedButton(
        hoverColor: Colors.blue,
        color: Colors.red,child: Text('管理员用户登录',style: TextStyle(color:Colors.white)),onPressed: () async{
          APIAccountManager.login('18046053193','654321',isAdminLogin: true,onSucc: (msg,userId){
            debugPrint(msg);
            debugPrint('用户ID: ' + userId.toString());
          },
          onFail: (msg){
            debugPrint(msg);
          });
      }),

      // 忘记密码获取验证码
      RaisedButton(
        color: Colors.red,
        hoverColor: Colors.blue,
        child: Text('忘记密码获取验证码',style: TextStyle(color:Colors.white)),onPressed: () async{
          APIAccountManager.requestPasswordResetBySmsCode('18046053193',onSucc: (msg){
            debugPrint(msg);
          },
          onFail: (msg){
            debugPrint(msg);
          });
      }),

      // 修改密码
      RaisedButton(
        color: Colors.red,
        hoverColor: Colors.blue,
        child: Text('修改密码',style: TextStyle(color:Colors.white)),onPressed: () async{
          APIAccountManager.resetPasswordBySmsCode('18046053193','465111','654321',onSucc: (msg){
            debugPrint(msg);
          },
          onFail: (msg){
            debugPrint(msg);
          });
      }),
      

      // 反馈问题列表
      RaisedButton(
        color: Colors.red,
        hoverColor: Colors.blue,
        child: Text('反馈问题列表',style: TextStyle(color:Colors.white)),onPressed: () async{
          
          APIFeedback.getProblemTypeList(
              onSucc: (list){
                debugPrint('记录数: ' + list.length.toString());
                for (final item in list) {
                  debugPrint(item.name + ',' + item.title);
                }
            },
            onFail: (msg){
              debugPrint(msg);
            }
          );
      }),

      // 提交问题反馈
      RaisedButton(
        hoverColor: Colors.blue,
        color: Colors.red,child: Text('提交问题反馈',style: TextStyle(color:Colors.white)),onPressed: () async{
          
          APIFeedback.commitProblemFeedBack(3,'东西不错','福州市',
              onSucc: (){
                debugPrint('提交成功');
            },
            onFail: (msg){
              debugPrint(msg);
            }
          );
          
      }),
      
      // 查询产品列表
      RaisedButton(
        hoverColor: Colors.blue,
        color: Colors.red,child: Text('所有产品',style: TextStyle(color:Colors.white)),onPressed: () async{
          
          APIProduct.getProductListAll(
              onSucc: (list){

                debugPrint('记录数: ' + list.length.toString());

                for (final item in list) {
                  debugPrint(item.name + ',' + item.coverUrl + ',' + item.productCategory.name + ',' + item.accessType.name);
                }
            },
            onFail: (msg){
              debugPrint(msg);
            }
          );
      }),

      // 所有SKU
      RaisedButton(
        hoverColor: Colors.blue,
        color: Colors.red,child: Text('所有 SKU',style: TextStyle(color:Colors.white)),onPressed: () async{
          
          APIProductSKU.getProductSKUList(onFail:(msg)=> debugPrint(msg),onSucc: (list){

                debugPrint('记录数: ' + list.length.toString());

                for (final item in list) {
                  debugPrint(item.toString());
                }
            },
          );

      }),

      // 提交新的SKU
      RaisedButton(
        hoverColor: Colors.blue,
        color: Colors.red,child: Text('提交 SKU',style: TextStyle(color:Colors.white)),onPressed: () async{
          
          APIProductSKU.commitProductSKU('skuTest',1,
          {
            "domain": "api.hsa.fjlead.com",
            "host": "27.148.136.253",
            "basePort": "8281",
            "agentPort": "8280",
            "livePort": "8282"
          },
          onFail:(msg)=> debugPrint(msg),onSucc:()=>debugPrint('提交成功'));

      }),



      // 提交操作日志(水吉水厂))
      RaisedButton(
        hoverColor: Colors.blue,
        color: Colors.red,child: Text('提交操作日志(水吉水厂)',style: TextStyle(color:Colors.white)),onPressed: () async{
          
          APIOperationLog.commitOperationLogSJSC('一键开机', '00010001', '1.1.1 build 12',onFail:(msg)=> debugPrint(msg),onSucc: (){
            debugPrint('提交成功');
          });

      }),

      // 获取ios版本信息
      RaisedButton(
        hoverColor: Colors.blue,
        color: Colors.red,child: Text('iOS版本信息',style: TextStyle(color:Colors.white)),onPressed: () async{
          
          APIPackageUpdate.getRemotePackageUpdateForIOS(onFail:(msg)=> debugPrint(msg),onSucc: (pkg){
            debugPrint(pkg.toString());
          });

      }),

      // 获取android版本信息
      RaisedButton(
        hoverColor: Colors.blue,
        color: Colors.red,child: Text('Android版本信息',style: TextStyle(color:Colors.white)),onPressed: () async{
          
          APIPackageUpdate.getRemotePackageUpdateForAndroid(onFail:(msg)=> debugPrint(msg),onSucc: (pkg){
            debugPrint(pkg.toString());
          });

      }),

      // 提交用户方案
      RaisedButton(
        hoverColor: Colors.blue,
        color: Colors.red,child: Text('提交用户方案',style: TextStyle(color:Colors.white)),onPressed: () async{
          
          APIScheme.commitScheme('用户测试方案2',5,onFail:(msg)=> debugPrint(msg),onSucc: (){
            debugPrint('提交成功');
          });

      }),


      // 获取当前用户下所有方案
      RaisedButton(
        hoverColor: Colors.blue,
        color: Colors.red,child: Text('获取当前用户下所有方案',style: TextStyle(color:Colors.white)),onPressed: () async{
          
          APIScheme.getAllSchemeListByCurrentUser(onFail:(msg)=> debugPrint(msg),onSucc: (list){
                debugPrint('记录数: ' + list.length.toString());
                for (final item in list) {
                  debugPrint(item.toString());
                }
          });

      }),

      // 获取当前用户下,根据品类Id获取方案列表
      RaisedButton(
        hoverColor: Colors.blue,
        color: Colors.red,child: Text('根据品类Id获取方案列表',style: TextStyle(color:Colors.white)),onPressed: () async{
          
          APIScheme.getSchemeListByCategoryId(2,onFail:(msg)=> debugPrint(msg),onSucc: (list){
                          debugPrint('记录数: ' + list.length.toString());
                for (final item in list) {
                  debugPrint(item.toString());
                }
          });

      }),

      
      // 获取右侧产品根据品类Id获取产品列表
      RaisedButton(
        hoverColor: Colors.blue,
        color: Colors.red,child: Text('根据品类Id获取产品列表',style: TextStyle(color:Colors.white)),onPressed: () async{
          
          APIProduct.getProductListByCategoryId(1,onFail:(msg)=> debugPrint(msg),onSucc: (list){
              debugPrint('记录数: ' + list.length.toString());
                for (final item in list) {
                  debugPrint(item.toString());
                }
          });

      }),


      // 获取当前用户信息
      RaisedButton(
        hoverColor: Colors.blue,
        color: Colors.red,child: Text('当前用户信息',style: TextStyle(color:Colors.white)),onPressed: () async{
          
          APIUser.currentUserInfo(onFail:(msg)=> debugPrint(msg),onSucc: (user){
            debugPrint(user.toString());
          });

      }),

      // 获取所有用户信息
      RaisedButton(
        hoverColor: Colors.blue,
        color: Colors.red,child: Text('所有用户信息表',style: TextStyle(color:Colors.white)),onPressed: () async{
          
          APIUser.getAllUserList(onFail:(msg)=> debugPrint(msg),onSucc: (list){
              debugPrint('记录数: ' + list.length.toString());
                for (final item in list) {
                  debugPrint(item.toString());
                }
          });

      }),

      // 根据产品ID获取SKU列表
      RaisedButton(
        hoverColor: Colors.blue,
        color: Colors.red,child: Text('根据产品ID获取SKU列表',style: TextStyle(color:Colors.white)),onPressed: () async{
          
          APIProductSKU.getProductSKUListByProductId(1,onFail:(msg)=> debugPrint(msg),onSucc: (list){
              debugPrint('记录数: ' + list.length.toString());
                for (final item in list) {
                  debugPrint(item.toString());
                }
          });

      }),


    ];
  }
}