更新消息设置
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import 'package:EasyDartModule/EasyDartModule.dart';
|
||||
import 'package:dio/dio.dart' as dio;
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutterflow_ui/flutterflow_ui.dart';
|
||||
import 'package:fluwx/fluwx.dart';
|
||||
import 'package:get_storage/get_storage.dart';
|
||||
import 'package:img_picker/img_picker.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
@@ -10,6 +12,8 @@ import 'package:vbvs_app/common/color/appConstants.dart';
|
||||
import 'package:vbvs_app/common/color/app_uri_status.dart';
|
||||
import 'package:vbvs_app/common/util/DailyLogUtils.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/common/util/requestWithLog.dart';
|
||||
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
|
||||
import 'package:vbvs_app/controller/device/body_device_controller.dart';
|
||||
import 'package:vbvs_app/controller/home/home_controller.dart';
|
||||
import 'package:vbvs_app/controller/login/login_controller.dart';
|
||||
@@ -67,6 +71,8 @@ class UserInfoController extends GetControllerEx<UserInfoModel> {
|
||||
List device_bind_status = [];
|
||||
int device_bind_flag = 0; //0。未初始化 1.已初始化
|
||||
int initLocationpermission = 0; //未初始化
|
||||
FluwxCancelable? fluwxCancelable;
|
||||
final Fluwx fluwx = Fluwx();
|
||||
|
||||
Future<ApiResponse> uploadImg() async {
|
||||
EasyDartModule.logger.info("请求上传图片");
|
||||
@@ -129,20 +135,29 @@ class UserInfoController extends GetControllerEx<UserInfoModel> {
|
||||
}
|
||||
|
||||
//更新用户信息
|
||||
Future<ApiResponse> updateData() async {
|
||||
Future<ApiResponse> updateData({
|
||||
String? phone,
|
||||
String? email,
|
||||
String? code,
|
||||
}) async {
|
||||
EasyDartModule.logger.info("更新用户资料");
|
||||
DailyLogUtils.writeLog("更新用户资料");
|
||||
try {
|
||||
LoginController loginController = Get.find();
|
||||
ApiResponse apiResponse = ApiResponse(code: -1, msg: "保存失败".tr);
|
||||
UserModel user = model.user!;
|
||||
if (user.tmpNickName == null || user.tmpNickName!.isEmpty) {
|
||||
apiResponse.msg = "昵称为空".tr;
|
||||
return apiResponse;
|
||||
}
|
||||
// if (user.tmpNickName!.length >= 9) {
|
||||
// apiResponse.msg = "最长字符为8个字".tr;
|
||||
// return apiResponse;
|
||||
// }
|
||||
if ((phone != null && phone.isNotEmpty) ||
|
||||
(email != null && email.isNotEmpty)) {
|
||||
if (loginController.model.updateCode == null ||
|
||||
loginController.model.updateCode!.isEmpty) {
|
||||
apiResponse.msg = "请输验证码".tr;
|
||||
return apiResponse;
|
||||
}
|
||||
}
|
||||
String serviceAddress = ServiceConstant.service_address;
|
||||
String serviceName = ServiceConstant.server_service;
|
||||
String serviceApi = ServiceConstant.user_info;
|
||||
@@ -168,8 +183,15 @@ class UserInfoController extends GetControllerEx<UserInfoModel> {
|
||||
"nickName": user.tmpNickName,
|
||||
if (user.tmpHead != null && user.tmpHead!.isNotEmpty)
|
||||
"avatar": user.tmpHead,
|
||||
if (phone != null && phone.isNotEmpty) "phone": phone,
|
||||
if (email != null && email.isNotEmpty) "email": email,
|
||||
if (loginController.model.updateCode != null &&
|
||||
loginController.model.updateCode!.isNotEmpty)
|
||||
"verify": loginController.model.updateCode,
|
||||
if (code != null && code.isNotEmpty) "wxCode": code,
|
||||
if (code != null && code.isNotEmpty) "khCode": "theh",
|
||||
"merge": true,
|
||||
};
|
||||
|
||||
var response =
|
||||
await EasyDartModule.dio.put(queryUrl, data: jsonEncode(data));
|
||||
if (apiResponse != null) {
|
||||
@@ -178,6 +200,10 @@ class UserInfoController extends GetControllerEx<UserInfoModel> {
|
||||
ApiResponse res =
|
||||
ApiResponse.fromJson(responseData, (object) => object);
|
||||
MyUtils.formatResponse(res, "保存成功".tr, "保存失败".tr);
|
||||
await getUserInfo();
|
||||
model.user!.tmpNickName = model.user!.nick_name;
|
||||
model.user!.tmpHead = model.user!.avatar;
|
||||
updateAll();
|
||||
return res;
|
||||
} else {
|
||||
return ApiResponse(code: -1, msg: "服务器失败".tr);
|
||||
@@ -304,4 +330,40 @@ class UserInfoController extends GetControllerEx<UserInfoModel> {
|
||||
|
||||
return apiResponse;
|
||||
}
|
||||
|
||||
//解除微信绑定
|
||||
unBindWx(BuildContext context) async {
|
||||
String serviceAddress = ServiceConstant.service_address;
|
||||
String serviceName = ServiceConstant.server_service;
|
||||
String serviceApi = ServiceConstant.user_info;
|
||||
String queryUrl = "${serviceAddress}${serviceName}${serviceApi}";
|
||||
try {
|
||||
final data = {
|
||||
"wxCode": "",
|
||||
"khCode": "",
|
||||
"merge": true,
|
||||
};
|
||||
final res = await requestWithLog(
|
||||
logTitle: "解除微信绑定",
|
||||
method: MyHttpMethod.put,
|
||||
queryUrl: queryUrl,
|
||||
data: data,
|
||||
onSuccess: (res) {
|
||||
TopSlideNotification.show(
|
||||
context,
|
||||
text: res.msg!,
|
||||
);
|
||||
},
|
||||
onFailure: (res) {
|
||||
TopSlideNotification.show(
|
||||
context,
|
||||
text: res.msg!,
|
||||
textColor: themeController.currentColor.sc9,
|
||||
);
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
ef.log("微信解绑失败-》$e");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user