Hibok
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

1451 lines
44 KiB

  1. import 'dart:convert';
  2. import 'package:chat/data/WebData.dart';
  3. import 'package:chat/data/chat_data_mgr.dart';
  4. import 'package:chat/data/constants.dart';
  5. import 'package:chat/data/group_data_mgr.dart';
  6. import 'package:chat/generated/i18n.dart';
  7. import 'package:chat/home/EditData.dart';
  8. import 'package:chat/home/IndexPage.dart';
  9. import 'package:chat/home/MoneyPage.dart';
  10. import 'package:chat/home/SelectSexPage.dart';
  11. import 'package:chat/models/ChatMsg.dart';
  12. import 'package:chat/models/UserInfo.dart';
  13. import 'package:chat/models/daily_bonus.dart';
  14. import 'package:chat/models/money_change.dart';
  15. import 'package:chat/proto/all.pbserver.dart';
  16. import 'package:chat/utils/LoadingDialog.dart';
  17. import 'package:chat/utils/MessageMgr.dart';
  18. import 'package:chat/utils/NetUtil.dart';
  19. import 'package:chat/utils/blacklist_mgr.dart';
  20. import 'package:chat/utils/friend_list_mgr.dart';
  21. import 'package:chat/utils/image_util.dart';
  22. import 'package:chat/utils/local_notification_util.dart';
  23. import 'package:chat/utils/sp_utils.dart';
  24. import 'package:chat/utils/sql_util.dart';
  25. import 'package:chat/utils/user_info_table.dart';
  26. import 'package:device_info/device_info.dart';
  27. import 'dart:core';
  28. import 'package:dio/dio.dart';
  29. import 'package:flutter/material.dart';
  30. import 'package:flutter_inapp_purchase/flutter_inapp_purchase.dart';
  31. import 'package:oktoast/oktoast.dart';
  32. import 'package:provider/provider.dart';
  33. import 'package:shared_preferences/shared_preferences.dart';
  34. import 'dart:io';
  35. import '../data/UserData.dart';
  36. import '../utils/TokenMgr.dart';
  37. import 'package:http_parser/http_parser.dart';
  38. import 'package:chat/utils/friend_list_mgr.dart';
  39. class HttpUtil {
  40. static HttpUtil _instance;
  41. Dio dio;
  42. BaseOptions options;
  43. //static const String BaseUrl = 'http://192.168.0.223:7001/';
  44. //static const String BaseUrl = 'http://192.168.0.207:9080/';
  45. static const String BaseUrl = 'http://120.79.107.63:9080/';
  46. //static const String BaseUrl = 'http://192.168.0.177:9016/';
  47. // static const String BaseUrl = 'https://datasm.chengyouhd.com/';
  48. static HttpUtil _getInstance() {
  49. if (_instance == null) {
  50. _instance = HttpUtil._();
  51. }
  52. return _instance;
  53. }
  54. factory HttpUtil() => _getInstance();
  55. Map friendCache = {};
  56. HttpUtil._() {
  57. options = BaseOptions(
  58. baseUrl: BaseUrl,
  59. headers: {},
  60. );
  61. dio = new Dio(options);
  62. // (dio.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate =
  63. // (HttpClient client) {
  64. // client.findProxy = (uri) {
  65. // //proxy all request to localhost:8888
  66. // return "PROXY 192.168.0.181:8888";
  67. // };
  68. // client.badCertificateCallback =
  69. // (X509Certificate cert, String host, int port) => true;
  70. // };
  71. dio.interceptors
  72. .add(InterceptorsWrapper(onRequest: (RequestOptions options) async {
  73. // Do something before request is sent
  74. return options; //continue
  75. // If you want to resolve the request with some custom data,
  76. // you can return a `Response` object or return `dio.resolve(data)`.
  77. // If you want to reject the request with a error message,
  78. // you can return a `DioError` object or return `dio.reject(errMsg)`
  79. }, onResponse: (Response response) async {
  80. // Do something with response data
  81. return response; // continue
  82. }, onError: (DioError e) async {
  83. // Do something with response error
  84. showToast(I18n.of(Constants.getCurrentContext()).net_error);
  85. return e; //continue
  86. }));
  87. }
  88. Future get(url, {data, options, cancelToken}) async {
  89. print('get请求启动! url:$url ,body: $data');
  90. Response response;
  91. try {
  92. response = await dio.get(
  93. url,
  94. queryParameters: data,
  95. cancelToken: cancelToken,
  96. );
  97. print('get请求成功!$url');
  98. } on DioError catch (e) {
  99. if (CancelToken.isCancel(e)) {
  100. print('get请求取消! ' + e.message);
  101. }
  102. print('get请求发生错误:$e');
  103. }
  104. return response;
  105. }
  106. getFriendList(callback) async {
  107. Map data = {
  108. "userId": UserData().basicInfo.userId,
  109. };
  110. data['sign'] = TokenMgr().getSign(data);
  111. Response res = await HttpUtil().post('friendship/friends/list', data: data);
  112. Map resData = res.data;
  113. if (resData['code'] == 0) {
  114. if (callback != null) callback(resData['data']);
  115. }
  116. }
  117. Future getDataWX(url, {data, options, cancelToken}) async {
  118. print('get请求启动! url:$url ,body: $data');
  119. Response response;
  120. BaseOptions options = BaseOptions(
  121. headers: {},
  122. );
  123. Dio dio = new Dio(options);
  124. try {
  125. response = await dio.get(
  126. url,
  127. queryParameters: data,
  128. cancelToken: cancelToken,
  129. );
  130. print('get请求成功!$url');
  131. } on DioError catch (e) {
  132. if (CancelToken.isCancel(e)) {
  133. print('get请求取消! ' + e.message);
  134. }
  135. print('get请求发生错误:$e');
  136. }
  137. return response;
  138. }
  139. Future post(url,
  140. {data,
  141. options,
  142. cancelToken,
  143. bool isShowLoading = false,
  144. failback}) async {
  145. print('post请求启动! url:$url ,body: $data');
  146. Response response;
  147. if (isShowLoading) LoadingManage().showLoading();
  148. try {
  149. response = await dio.post(
  150. url,
  151. data: data,
  152. cancelToken: cancelToken,
  153. );
  154. print('$url post请求成功! $BaseUrl');
  155. if (isShowLoading) LoadingManage().closeLoading();
  156. } on DioError catch (e) {
  157. if (CancelToken.isCancel(e)) {
  158. print('post请求取消! ' + e.message);
  159. }
  160. print('post请求发生错误:$e');
  161. if (isShowLoading) LoadingManage().closeLoading();
  162. showToast(I18n.of(Constants.getCurrentContext()).server_error_tips);
  163. if (failback != null) failback();
  164. }
  165. return response;
  166. }
  167. // 上传文件
  168. Future uploadFile(File imgfile, data, url, contentType,
  169. {isShowLoading = false}) async {
  170. FormData formData = new FormData.fromMap({
  171. "type": data["type"],
  172. "userId": data["userId"],
  173. "sex": data['sex'] == null ? 0 : data['sex'],
  174. "isBurn": data['isBurn'] == null ? 0 : data['isBurn'],
  175. "sign": data['sign'],
  176. "file": await getMultipartFile(imgfile, contentType)
  177. });
  178. print('post请求启动! url:$url');
  179. if (isShowLoading) LoadingManage().showLoading();
  180. Response response;
  181. try {
  182. response = await dio.post(
  183. url,
  184. data: formData,
  185. );
  186. print('post请求成功!response.data:${response.data}');
  187. if (isShowLoading) LoadingManage().closeLoading();
  188. } on DioError catch (e) {
  189. if (CancelToken.isCancel(e)) {
  190. print('post请求取消! ' + e.message);
  191. }
  192. print('post请求发生错误:$e');
  193. if (isShowLoading) LoadingManage().closeLoading();
  194. }
  195. return response;
  196. }
  197. Future<MultipartFile> getMultipartFile(
  198. File imgfile, String contentType) async {
  199. //压缩图片文件
  200. var size = await imgfile.length();
  201. String path = imgfile.path;
  202. var fileBytes;
  203. if (contentType == 'image' && size > 10240) {
  204. fileBytes =
  205. await WidgetUtil.getCompressImg(path, quality: 80, percentage: 80);
  206. } else {
  207. fileBytes = imgfile.readAsBytesSync();
  208. }
  209. var name = path.substring(path.lastIndexOf("/") + 1, path.length);
  210. var suffix = name.substring(name.lastIndexOf(".") + 1, name.length);
  211. return new MultipartFile.fromBytes(fileBytes,
  212. filename: name, contentType: MediaType(contentType, suffix));
  213. }
  214. // 上传多个图片
  215. Future uploadFiles(List<File> imgfileList, data, url, contentType,
  216. {isShowLoading = false}) async {
  217. var imgList = [];
  218. for (int i = 0; i < imgfileList.length; i++) {
  219. imgList.add(await getMultipartFile(imgfileList[i], contentType));
  220. }
  221. FormData formData = new FormData.fromMap({
  222. "type": data["type"],
  223. "userId": data["userId"],
  224. "sex": data['sex'] == null ? 0 : data['sex'],
  225. "isBurn": data['isBurn'] == null ? 0 : data['isBurn'],
  226. "sign": data['sign'],
  227. "file": imgList
  228. });
  229. print('post请求启动! url:$url');
  230. if (isShowLoading) LoadingManage().showLoading();
  231. Response response;
  232. try {
  233. response = await dio.post(
  234. url,
  235. data: formData,
  236. );
  237. print('post请求成功!response.data:${response.data}');
  238. if (isShowLoading) LoadingManage().closeLoading();
  239. } on DioError catch (e) {
  240. if (CancelToken.isCancel(e)) {
  241. print('post请求取消! ' + e.message);
  242. }
  243. print('post请求发生错误:$e');
  244. if (isShowLoading) LoadingManage().closeLoading();
  245. }
  246. return response;
  247. }
  248. Future getUserInfoFromServer(int friendId) async {
  249. Map<String, dynamic> data = {
  250. "visitUserId": UserData().basicInfo.userId,
  251. "userId": friendId,
  252. "language": UserData().language,
  253. };
  254. data['sign'] = TokenMgr().getSign(data);
  255. data['lat'] = UserData().latitude;
  256. data['lng'] = UserData().longitude;
  257. print('请求用户信息 $data}');
  258. print('从服务器获取用户信息$friendId');
  259. Response res = await HttpUtil().post('user/info/list', data: data);
  260. if (res == null) {
  261. return null;
  262. }
  263. Map resData = res.data;
  264. print('用户信息resData $resData');
  265. if (resData['code'] == 0) {
  266. var info = UserInfo.fromJson(resData['data']);
  267. info.isBlackened
  268. ? BlacklistMgr.addBlackListMe(info.userId)
  269. : BlacklistMgr.removeBalckListMe(info.userId);
  270. info.isBlackList
  271. ? BlacklistMgr.addMyBlackList(info.userId)
  272. : BlacklistMgr.removeMyBalckList(info.userId);
  273. friendCache[friendId] = info;
  274. FriendListMgr().updateFriendInfo(info);
  275. UserInfoTable().insertUser(info);
  276. MessageMgr().emit('UpdateUserInfo', info);
  277. return info;
  278. } else {
  279. return null;
  280. }
  281. }
  282. Future getFriendInfo(int friendId, [bool isUpdate = false]) async {
  283. print('开始获取用户信息$friendId');
  284. if (friendId == null) {
  285. print('用户Id为空,无法获取信息');
  286. return null;
  287. }
  288. if (friendCache[friendId] != null) {
  289. print('存在用户信息$friendId 缓存');
  290. if (isUpdate) {
  291. //如果需要更新,那么先读取旧数据,然后后台更新
  292. getUserInfoFromServer(friendId);
  293. }
  294. return friendCache[friendId];
  295. }
  296. var info = await SqlUtil.userInfoTable.getUserInfoFromLocal(friendId);
  297. print('从本地数据库读取用户$friendId 信息');
  298. if (info != null) {
  299. if (isUpdate) {
  300. //如果需要更新,那么先读取旧数据,然后后台更新
  301. getUserInfoFromServer(friendId);
  302. }
  303. friendCache[friendId] = info;
  304. return info;
  305. }
  306. return await getUserInfoFromServer(friendId);
  307. }
  308. getUserInfo(visitedUserId, [callback, failcallback, errorcallback]) async {
  309. var data = {
  310. "visitUserId": UserData().basicInfo.userId,
  311. "userId": visitedUserId,
  312. "language": UserData().language,
  313. };
  314. data['sign'] = TokenMgr().getSign(data);
  315. data['lat'] = UserData().latitude;
  316. data['lng'] = UserData().longitude;
  317. Response res = await HttpUtil()
  318. .post('user/info/list', data: data, failback: errorcallback);
  319. if (res == null) {
  320. print('请求异常');
  321. return;
  322. }
  323. Map resData = res.data;
  324. if (resData['code'] == 0) {
  325. var info = UserInfo.fromJson(resData['data']);
  326. info.isBlackened
  327. ? BlacklistMgr.addBlackListMe(info.userId)
  328. : BlacklistMgr.removeBalckListMe(info.userId);
  329. info.isBlackList
  330. ? BlacklistMgr.addMyBlackList(info.userId)
  331. : BlacklistMgr.removeMyBalckList(info.userId);
  332. FriendListMgr().updateFriendInfo(info);
  333. friendCache[info.userId] = info;
  334. MessageMgr().emit('UpdateUserInfo', info);
  335. if (callback != null) callback(resData['data']);
  336. } else if (resData['code'] == -4) {
  337. if (failcallback != null) failcallback();
  338. }
  339. }
  340. getFirstProgram() async {
  341. Map data = {
  342. "userId": UserData().basicInfo.userId,
  343. "visitUserId": UserData().basicInfo.userId,
  344. "type": 1,
  345. };
  346. data['sign'] = TokenMgr().getSign(data);
  347. data['page'] = 1;
  348. data['rows'] = 1;
  349. Response res = await HttpUtil().post('station/gain/program', data: data);
  350. if (res == null) {
  351. print('请求异常');
  352. return;
  353. }
  354. var resData = res.data;
  355. if (resData['code'] == 0) {
  356. UserData().isCanProgram =
  357. resData['data'] == null || resData['data'][0]['Status'] == 1;
  358. }
  359. }
  360. Future getTranslateState(int sessionId) async {
  361. Map data = {
  362. "userId": UserData().basicInfo.userId,
  363. "chatUserId": sessionId,
  364. };
  365. data['sign'] = TokenMgr().getSign(data);
  366. Response res =
  367. await HttpUtil().post('translate/get/user/status', data: data);
  368. if (res == null) {
  369. print('请求异常');
  370. return null;
  371. }
  372. var resData = res.data;
  373. if (resData['code'] == 0) {
  374. return resData['data'];
  375. }
  376. return null;
  377. }
  378. updateTranslateState(int sessionId, bool state) async {
  379. Map data = {
  380. "userId": UserData().basicInfo.userId,
  381. "chatUserId": sessionId,
  382. "status": state ? 1 : 0
  383. };
  384. data['sign'] = TokenMgr().getSign(data);
  385. Response res = await HttpUtil().post('translate/set/up/status', data: data);
  386. if (res == null) {
  387. print('请求异常');
  388. return false;
  389. }
  390. var resData = res.data;
  391. if (resData['code'] == 0) {
  392. return true;
  393. }
  394. return false;
  395. }
  396. changeLanguage(BuildContext context, lang, callback,
  397. [showLoading = false]) async {
  398. var data = {
  399. "userid": UserData().basicInfo.userId,
  400. "language": lang,
  401. };
  402. data['sign'] = TokenMgr().getSign(data);
  403. try {
  404. Response res = await HttpUtil().post('user/setting/language',
  405. data: data, isShowLoading: showLoading);
  406. if (res == null) {
  407. print('请求异常');
  408. return;
  409. }
  410. Map resData = res.data;
  411. if (resData['code'] == 0) {
  412. if (callback != null) callback();
  413. //重新登录
  414. // SocketUtil().reLogin();
  415. NetWork().reLogin();
  416. }
  417. } catch (e) {}
  418. }
  419. userFreeTime(BuildContext context, var viewUserId, int type, callback) async {
  420. Map data = {
  421. "userId": UserData().basicInfo.userId,
  422. "viewUserId": viewUserId,
  423. 'type': type,
  424. };
  425. data['sign'] = TokenMgr().getSign(data);
  426. try {
  427. Response res = await HttpUtil()
  428. .post('photos/unlock/permissions', data: data, isShowLoading: true);
  429. if (res == null) {
  430. print('请求异常');
  431. return;
  432. }
  433. Map resData = res.data;
  434. if (resData['code'] == 0) {
  435. if (callback != null) callback();
  436. }
  437. } catch (e) {}
  438. }
  439. saveAotuLoginKey(resData, {bool isSaveUserId = true}) async {
  440. //将用户信息存到本地
  441. if (resData['data']['aotuLoginKey'] != null) {
  442. SharedPreferences prefs = await SharedPreferences.getInstance();
  443. await prefs.setString(
  444. Constants.AutoLoginKey, resData['data']['aotuLoginKey']);
  445. if (isSaveUserId) {
  446. await prefs.setInt(Constants.LocalUserId, UserData().basicInfo.userId);
  447. }
  448. }
  449. }
  450. ///登录
  451. changePage(BuildContext context, Map resData) async {
  452. UserData().basicInfo.userId = resData['data']['userid'];
  453. UserData().basicInfo.sex = resData['data']['sex'];
  454. if (resData['data']['mobile'] != null && resData['data']['mobile'] != '') {
  455. UserData().mobile = int.parse(resData['data']['mobile']);
  456. }
  457. if (resData['data']['bindId'] != null) {
  458. UserData().agentId = resData['data']['bindId'];
  459. }
  460. //读取聊天信息
  461. await ChatDataMgr().initMsg();
  462. //读取群信息
  463. await GroupInfoMgr().initLocalGroupList();
  464. print('~~~~~~~~~~~~~changePage~~~~~~~~~~~~~~~~~~~~~~');
  465. changeLanguage(context, UserData().language, null);
  466. getRewardAndRedPacketState();
  467. //clearReadData(UserData().basicInfo.userId);
  468. if (resData['data']['sex'] == 0) {
  469. Navigator.of(context).push(
  470. new MaterialPageRoute(
  471. builder: (context) {
  472. return SelectSex();
  473. },
  474. ),
  475. );
  476. saveAotuLoginKey(resData, isSaveUserId: false);
  477. return;
  478. }
  479. if (resData['data']['info'] == 0) {
  480. Navigator.of(context).push(
  481. new MaterialPageRoute(
  482. builder: (context) {
  483. return EditPage(
  484. isEditPage: false,
  485. );
  486. },
  487. ),
  488. );
  489. saveAotuLoginKey(resData, isSaveUserId: false);
  490. return;
  491. }
  492. checkFriends();
  493. LocalNotificationUtil.instance.startPush();
  494. //ChatDataMgr().initMsg();
  495. Navigator.of(context)
  496. .pushNamedAndRemoveUntil('/main', (route) => route == null);
  497. MessageMgr().emit('update_system');
  498. saveAotuLoginKey(resData);
  499. getFirstProgram();
  500. initLocation();
  501. }
  502. initLocation() async {
  503. SharedPreferences prefs = await SharedPreferences.getInstance();
  504. var latitude = prefs.getDouble(Constants.Latitude);
  505. var longitude = prefs.getDouble(Constants.Longitude);
  506. print('存贮在本地的位置: $latitude------$longitude');
  507. if (latitude != null) UserData().latitude = latitude;
  508. if (longitude != null) UserData().longitude = longitude;
  509. }
  510. setPhote(BuildContext context, id, type, callback) async {
  511. var data = {
  512. "userId": UserData().basicInfo.userId,
  513. "type": type,
  514. "pId": id,
  515. };
  516. data['sign'] = TokenMgr().getSign(data);
  517. Response res = await HttpUtil()
  518. .post('photos/setting/burns', data: data, isShowLoading: true);
  519. if (res == null) {
  520. print('请求异常');
  521. return;
  522. }
  523. var resData = res.data;
  524. showToast(resData['msg']);
  525. if (resData['code'] == 0) {
  526. if (callback != null) callback();
  527. }
  528. }
  529. clearCacheData() async {
  530. print('######### 清除缓存key');
  531. SharedPreferences prefs = await SharedPreferences.getInstance();
  532. prefs.remove(Constants.AutoLoginKey);
  533. prefs.remove(Constants.LocalUserId);
  534. prefs.remove(Constants.LocalUsrInfo);
  535. }
  536. // clearReadData(userId) async {
  537. // SharedPreferences prefs = await SharedPreferences.getInstance();
  538. // var localUserId = prefs.getInt(Constants.LocalUserId);
  539. // if (userId != localUserId) {
  540. // prefs.remove(Constants.ApplyCount);
  541. // prefs.remove(Constants.EvaluateCount);
  542. // prefs.remove(Constants.ParkCount);
  543. // prefs.remove(Constants.CastCount);
  544. // prefs.remove(Constants.WalletCount);
  545. // }
  546. // }
  547. void postLoginOut(BuildContext context) async {
  548. Map data = {
  549. "userId": UserData().basicInfo.userId,
  550. };
  551. data['sign'] = TokenMgr().getSign(data);
  552. Response res = await HttpUtil().post('user/login/out', data: data);
  553. if (res == null) {
  554. print('请求异常');
  555. return;
  556. }
  557. Map resData = res.data;
  558. if (resData['code'] == 0) {
  559. clearCacheData();
  560. FriendListMgr().friendList?.clear();
  561. Navigator.of(context).pushAndRemoveUntil(new MaterialPageRoute(
  562. builder: (context) {
  563. return IndexPage();
  564. },
  565. ), (route) => route == null);
  566. NetWork().singOut();
  567. UserData().reset();
  568. } else {
  569. showToast(resData['msg']);
  570. }
  571. }
  572. buyGoods(money, goodsId, detailtype, changeuserId, context, callback) async {
  573. if (Provider.of<MoneyChangeProvider>(context).money < money) {
  574. showToast(I18n.of(context).balance_insufficien);
  575. return;
  576. }
  577. var data = {
  578. "userId": UserData().basicInfo.userId,
  579. "type": 1,
  580. "detailtype": detailtype,
  581. };
  582. data['sign'] = TokenMgr().getSign(data);
  583. data['value'] = money;
  584. data['changeuserId'] = changeuserId;
  585. data['membergoodsId'] = goodsId;
  586. Response res = await HttpUtil()
  587. .post('wealth/user/add', data: data, isShowLoading: true);
  588. if (res == null) {
  589. print('请求异常');
  590. return;
  591. }
  592. Map resData = res.data;
  593. showToast(resData['msg']);
  594. if (resData['code'] == 0) {
  595. Provider.of<MoneyChangeProvider>(context, listen: false).subMoney(money);
  596. if (callback != null) callback();
  597. }
  598. }
  599. buyPictures(money, changeuserId, context, callback) async {
  600. if (Provider.of<MoneyChangeProvider>(context).money < money) {
  601. showToast(I18n.of(context).balance_insufficien);
  602. return;
  603. }
  604. var data = {
  605. "userId": UserData().basicInfo.userId,
  606. "viewUserId": changeuserId,
  607. "price": money,
  608. };
  609. data['sign'] = TokenMgr().getSign(data);
  610. Response res = await HttpUtil()
  611. .post('photos/user/unlock', data: data, isShowLoading: true);
  612. if (res == null) {
  613. print('请求异常');
  614. return;
  615. }
  616. Map resData = res.data;
  617. showToast(resData['msg']);
  618. if (resData['code'] == 0) {
  619. Provider.of<MoneyChangeProvider>(context, listen: false).subMoney(money);
  620. if (callback != null) callback();
  621. }
  622. }
  623. buyVIP(int money, int gid, int type, BuildContext context, callback) async {
  624. if (Provider.of<MoneyChangeProvider>(context).money < money) {
  625. showToast(I18n.of(context).balance_insufficien);
  626. return;
  627. }
  628. Map data = {
  629. "userId": UserData().basicInfo.userId,
  630. "gid": gid,
  631. "type": type,
  632. "price": money,
  633. };
  634. data['sign'] = TokenMgr().getSign(data);
  635. Response res = await HttpUtil()
  636. .post('goods/user/purchase', data: data, isShowLoading: true);
  637. if (res == null) {
  638. print('请求异常');
  639. return;
  640. }
  641. Map resData = res.data;
  642. showToast(resData['msg']);
  643. if (resData['code'] == 0) {
  644. Provider.of<MoneyChangeProvider>(context, listen: false).subMoney(money);
  645. if (callback != null) callback();
  646. }
  647. }
  648. buyChatAccount(money, changeuserId, context, callback) async {
  649. if (Provider.of<MoneyChangeProvider>(context).money < money) {
  650. showToast(I18n.of(context).balance_insufficien);
  651. return;
  652. }
  653. var data = {
  654. "userId": UserData().basicInfo.userId,
  655. "unlockUserId": changeuserId,
  656. "price": money,
  657. };
  658. data['sign'] = TokenMgr().getSign(data);
  659. Response res = await HttpUtil()
  660. .post('photos/pay/unlock/chat', data: data, isShowLoading: true);
  661. if (res == null) {
  662. print('请求异常');
  663. return;
  664. }
  665. Map resData = res.data;
  666. showToast(resData['msg']);
  667. if (resData['code'] == 0) {
  668. Provider.of<MoneyChangeProvider>(context, listen: false).subMoney(money);
  669. if (callback != null) callback();
  670. }
  671. }
  672. void getMoneyInfo(BuildContext context, callback) async {
  673. if (Platform.isIOS) {
  674. await MoneyPageState.initPayConf(context);
  675. }
  676. Map data = {
  677. "userid": UserData().basicInfo.userId,
  678. "moneytype":
  679. UserData().language == LanguageType.SimplifiedChinese ? 0 : 1,
  680. "mobiletype": Platform.isIOS ? 0 : 1,
  681. };
  682. if (Platform.isIOS) {
  683. data['moneytype'] = 1;
  684. }
  685. print('moneytype ${data['moneytype']}');
  686. data['sign'] = TokenMgr().getSign(data);
  687. Response res = await HttpUtil()
  688. .post('goods/info/list', data: data, isShowLoading: true);
  689. if (res == null) {
  690. print('请求异常');
  691. return;
  692. }
  693. Map resData = res.data;
  694. if (resData['code'] == 0) {
  695. if (callback != null) callback(resData['data']);
  696. }
  697. }
  698. void getWealth(BuildContext context, callback) async {
  699. Map data = {
  700. "userId": UserData().basicInfo.userId,
  701. };
  702. data['sign'] = TokenMgr().getSign(data);
  703. Response res = await HttpUtil().post('wealth/user/info', data: data);
  704. if (res == null) {
  705. print('请求异常');
  706. return;
  707. }
  708. Map resData = res.data;
  709. print(resData);
  710. if (resData['code'] == 0 && resData['data'] != null) {
  711. UserData().basicInfo.isMember = resData['data']['IsMember'] ?? 0;
  712. UserData().incomeMoney = resData['data']['IncomeCoin'];
  713. UserData().frozenMoney = resData['data']['FrozenCoin'];
  714. UserData().memberEndTime = resData['data']['MemberEnd'];
  715. if (callback != null) callback(resData['data']);
  716. }
  717. }
  718. //获取红包与打赏开关状态
  719. getRewardAndRedPacketState() async {
  720. var myId = UserData().basicInfo.userId;
  721. Map data = {
  722. "userId": myId,
  723. };
  724. data['sign'] = TokenMgr().getSign(data);
  725. Response res = await HttpUtil().post('system/switch', data: data);
  726. if (res == null) {
  727. print('请求异常');
  728. return;
  729. }
  730. Map resData = res.data;
  731. print('### system/switch' + resData.toString());
  732. if (resData['code'] == 0) {
  733. var config = resData['data'];
  734. if (config != null) {
  735. UserData().redPacketSW = config['redPacket'];
  736. UserData().giftSwitch = config['reward'];
  737. UserData().bannerZF = config['iapPay'];
  738. UserData().sign = config['sign'];
  739. UserData().groupQRCode = config['groupQRCode'];
  740. UserData().addFdDistanceSwitch = config['distance'] ?? 0;
  741. UserData().stationOpenSwitch = config['station'] == 1;
  742. UserData().myProgramOpenSwitch = config['myProgram'] == 1;
  743. UserData().nearbyOpenSwitch = config['nearby'] == 1;
  744. // print('### config: start');
  745. // print('### config: iapPay:${config['iapPay']}');
  746. }
  747. }
  748. }
  749. ///检查是否有缓存的内购单-有的话向服务器发送请求重新创建订单
  750. void checkReceiptCache() async {
  751. String str = await SPUtils.get(Constants.IOS_IAP_Receipt);
  752. if (str != null && str.isNotEmpty) {
  753. print('### 有缓存单');
  754. List<String> split = str.split("@");
  755. createOrder(split[0], split[1], split[2]);
  756. } else {
  757. print('### 没有缓存单');
  758. }
  759. }
  760. ///ios内购-创建订单
  761. void createOrder(String currentGoodsId, String receipt, String purchaseToken,
  762. {BuildContext context}) async {
  763. // String base84str = base64Encode(utf8.encode(receipt));
  764. var data = {
  765. "userid": UserData().basicInfo.userId,
  766. "moneytype": 1,
  767. 'gid': currentGoodsId,
  768. "payway": 1,
  769. };
  770. data['sign'] = TokenMgr().getSign(data);
  771. data['receipt'] = receipt;
  772. data['isenable'] = Constants.isSandbox ? 0 : 1;
  773. Response res = await HttpUtil().post('order/add/goods', data: data);
  774. print('#### 创建订单-返回');
  775. if (res == null) {
  776. print('请求异常');
  777. return;
  778. }
  779. Map resData = res.data;
  780. print('#### 创建订单-返回:' + resData.toString());
  781. if (resData['code'] == 0) {
  782. // String OrderNo = resData['data']['OrderNo'];
  783. Future.delayed(Duration(seconds: 3), () {
  784. MessageMgr().emit('refresh_money');
  785. });
  786. if (context == null) {
  787. await FlutterInappPurchase.instance.initConnection;
  788. }
  789. FlutterInappPurchase.instance.finishTransaction(purchaseToken);
  790. SPUtils.remove(Constants.IOS_IAP_Receipt);
  791. } else {
  792. ///创建订单失败-
  793. await SPUtils.saveString(Constants.IOS_IAP_Receipt,
  794. currentGoodsId + '@' + receipt + '@' + purchaseToken);
  795. }
  796. if (context != null) {
  797. Navigator.of(context).pop();
  798. }
  799. }
  800. ///登陆
  801. void login(
  802. String _phoneNumber, String _passWorld, BuildContext context) async {
  803. var data = {
  804. "mobile": _phoneNumber,
  805. "text": _passWorld,
  806. "type": 0,
  807. "language": UserData().language,
  808. };
  809. data['sign'] = TokenMgr().getSign(data);
  810. Response res = await HttpUtil()
  811. .post('user/mobile/login', data: data, isShowLoading: true);
  812. if (res == null) {
  813. print('请求异常');
  814. return;
  815. }
  816. var resData = res.data;
  817. if (resData['code'] == 0 && resData['data'] != null) {
  818. HttpUtil().changePage(context, resData);
  819. } else {
  820. showToast(resData['msg']);
  821. }
  822. }
  823. ///获取推送设置
  824. getSettingInfo() async {
  825. Map data = {
  826. "userId": UserData().basicInfo.userId,
  827. "sex": UserData().basicInfo.sex,
  828. };
  829. data['sign'] = TokenMgr().getSign(data);
  830. try {
  831. Response res = await HttpUtil().post('message/push/message', data: data);
  832. if (res == null) {
  833. print('请求异常');
  834. return;
  835. }
  836. Map resData = res.data;
  837. bool isMan = UserData().isMan();
  838. ///女号 {data: {PrivacyChat: 1, NewBroadcast: 1, ApplyCheck: 1, CheckAccount: 1, CheckPhoto: 1, SendAccount: 1}, code: 0, msg: 成功}
  839. ///男号 {data: {PrivacyChat: 1, NewBroadcast: 1, AcceptCheck: 1, ApplySuccess: 1}, code: 0, msg: 成功}
  840. print('###settingdata res.data ${res.data}');
  841. if (resData['code'] == 0) {
  842. UserData().privatyMsgPushSwitch = resData['data']['PrivacyChat'] == 1;
  843. UserData().newDateSwitch = resData['data']['NewBroadcast'] == 1;
  844. if (isMan) {
  845. UserData().acceptCheckSwitch = resData['data']['AcceptCheck'] == 1;
  846. UserData().codeSucessSwitch = resData['data']['ApplySuccess'] == 1;
  847. } else {
  848. UserData().applyCheckSwitch = resData['data']['ApplyCheck'] == 1;
  849. UserData().checkPhotoSwitch = resData['data']['CheckPhoto'] == 1;
  850. }
  851. }
  852. } catch (e) {}
  853. MessageMgr().emit(MessageMgr.REFRESH_PUSH_PERMISSION);
  854. }
  855. ///版本控制
  856. appVersionUpdate(Function callBack) async {
  857. Map data = {
  858. "ditch": Constants.isStoreVersion ? 0 : 1,
  859. "type": Platform.isAndroid ? 0 : 1,
  860. };
  861. data['sign'] = TokenMgr().getSign(data);
  862. data['language'] = UserData().language;
  863. try {
  864. Response res = await HttpUtil().post('system/version/info', data: data);
  865. Map resData = res.data;
  866. print('###appVersionUpdate res.data ${res.data}');
  867. if (resData['code'] == 0) {
  868. bool needNotice = resData['data']['Notice'] == 1;
  869. ///是否通知更新
  870. bool forceUpdate = resData['data']['IsStronger'] == 1;
  871. ///是否通知强更
  872. String version = resData['data']['VersionNo'];
  873. String describe = resData['data']['Describe'];
  874. String downloadUrl = resData['data']['DownloadUrl'];
  875. String appId = resData['data']['AppId'];
  876. callBack(
  877. needNotice, forceUpdate, version, describe, downloadUrl, appId);
  878. }
  879. } catch (e) {}
  880. }
  881. downloadApk(
  882. BuildContext context,
  883. String filePath,
  884. String downloadUrl,
  885. Function downloadCallback,
  886. ) async {
  887. final file = new File(filePath);
  888. bool isExist = await file.exists();
  889. if (isExist) {
  890. print('### 文件存在 : ${file.path}');
  891. file.delete();
  892. }
  893. // else {
  894. //
  895. // print('### 开始下载 $downloadUrl');
  896. // dio.download(downloadUrl, filePath, onReceiveProgress: downloadCallback);
  897. // }
  898. // downloadUrl ='oemarket.com/app0/30/30970/apk/2085562.apk?channel_id=426&tid=d73j9ihlkucuxfqpgnxgjeif';
  899. dio.download(downloadUrl, filePath, onReceiveProgress: downloadCallback);
  900. }
  901. ///获取用户每日签到信息
  902. Future<DailyBonusBean> getDailyBonus() async {
  903. Map data = {
  904. "userId": UserData().basicInfo.userId,
  905. };
  906. data['sign'] = TokenMgr().getSign(data);
  907. data['userId'] = UserData().basicInfo.userId;
  908. try {
  909. Response res = await HttpUtil().post('sign/in/user/info', data: data);
  910. Map resData = res.data;
  911. print('###getDailyBonus res.data ${res.data}');
  912. if (resData['code'] == 0) {
  913. return DailyBonusBean.fromMap(resData['data']);
  914. }
  915. return null;
  916. } catch (e) {
  917. return null;
  918. }
  919. }
  920. ///点击签到
  921. Future<bool> signInBounus(int score) async {
  922. Map data = {
  923. "userId": UserData().basicInfo.userId,
  924. "score": score,
  925. };
  926. data['sign'] = TokenMgr().getSign(data);
  927. data['userId'] = UserData().basicInfo.userId;
  928. data['score'] = score;
  929. try {
  930. Response res = await HttpUtil().post('sign/in/user', data: data);
  931. Map resData = res.data;
  932. print('###signInBounus res.data ${res.data}');
  933. if (resData['code'] == 0) {
  934. return true;
  935. // bool needNotice = resData['data']['Notice']==1; ///是否通知更新
  936. // return DailyBonusBean.fromMap(resData['data']);
  937. } else {
  938. showToast(resData['msg']);
  939. }
  940. return false;
  941. } catch (e) {
  942. return false;
  943. }
  944. }
  945. /// 用户签到积分兑换商品
  946. Future<bool> signInExchange(GoodsBean goodsBean) async {
  947. Map data = {
  948. "userId": UserData().basicInfo.userId,
  949. "id": goodsBean.id,
  950. "score": goodsBean.s,
  951. };
  952. data['sign'] = TokenMgr().getSign(data);
  953. data['userId'] = UserData().basicInfo.userId;
  954. data['score'] = goodsBean.s;
  955. data['id'] = goodsBean.id;
  956. try {
  957. Response res =
  958. await HttpUtil().post('sign/in/score/exchange', data: data);
  959. Map resData = res.data;
  960. print('###signInExchange res.data ${res.data}');
  961. if (resData['code'] == 0) {
  962. return true;
  963. } else {
  964. showToast(resData['msg']);
  965. }
  966. return false;
  967. } catch (e) {
  968. return false;
  969. }
  970. }
  971. addFriends(
  972. BuildContext context, int friendId, String content, callback) async {
  973. Map data = {
  974. "userId": UserData().basicInfo.userId,
  975. "friendsUserId": friendId
  976. };
  977. data['sign'] = TokenMgr().getSign(data);
  978. data['content'] = content;
  979. Response res = await HttpUtil().post('friendship/add/friends', data: data);
  980. Map resData = res.data;
  981. print(resData);
  982. if (resData['code'] == 0) {
  983. showToast(resData['msg']);
  984. if (callback != null) callback();
  985. }
  986. }
  987. //付费人工翻译
  988. getPersonalTranslate(MsgModel msgModel) async {
  989. Map data = {
  990. "suserid": msgModel.from,
  991. "chatmsgid": msgModel.time,
  992. "slanguage": 1,
  993. "tlanguage": UserData().language,
  994. "chattype": msgModel.msgType,
  995. "chatchanneltype": msgModel.channelType,
  996. "targetid": msgModel.sessionId
  997. };
  998. data['sign'] = TokenMgr().getSign(data);
  999. if (msgModel.msgType == 0) {
  1000. data['content'] = base64Encode(msgModel.msgContent);
  1001. } else {
  1002. if (msgModel.localFile == null) {
  1003. showToast('请稍后再试');
  1004. return;
  1005. }
  1006. data['content'] =
  1007. base64Encode(File(msgModel.localFile).readAsBytesSync());
  1008. }
  1009. data["tuserids"] = [UserData().basicInfo.userId];
  1010. data['duration'] =
  1011. msgModel.extraInfo != null ? msgModel.extraInfo ~/ 1000 : 0;
  1012. data['ispay'] = true;
  1013. if (msgModel.msgType == ChatType.TextChatType.value) {
  1014. int length = utf8.decode(msgModel.msgContent).length;
  1015. data['money'] = length ~/ 50 + 1; //每50个字耗费1H币
  1016. print('字数 $length 价格 ${length % 50 + 1}');
  1017. } else if (msgModel.msgType == ChatType.ShortVoiceChatType.value) {
  1018. //没20秒扣除1Hb
  1019. data['money'] =
  1020. msgModel.extraInfo != null ? msgModel.extraInfo ~/ 20000 + 1 : 0;
  1021. }
  1022. if (msgModel.translateContent != null &&
  1023. msgModel.translateContent.length > 0) {
  1024. data['mcontent'] = base64Encode(msgModel.enTranslateContent);
  1025. }
  1026. Response res =
  1027. await HttpUtil().post('service/paid/translation', data: data);
  1028. if (res == null) {
  1029. return false;
  1030. }
  1031. Map resData = res.data;
  1032. print('付费翻译请求$resData');
  1033. if (resData['code'] == 0) {
  1034. print('扣除 H 币 ${data['money']}');
  1035. return true;
  1036. }
  1037. print(resData['msg']);
  1038. showToast(resData['msg']);
  1039. return false;
  1040. }
  1041. //用户评价人工翻译,差评
  1042. Future<bool> rateTranslateResult(MsgModel msg, Function callback) async {
  1043. Map data = {
  1044. "userId": UserData().basicInfo.userId,
  1045. "chatUserId": msg.from,
  1046. "chatMsgId": msg.time,
  1047. "score": 1
  1048. };
  1049. data['sign'] = TokenMgr().getSign(data);
  1050. Response res = await HttpUtil().post('translate/user/score', data: data);
  1051. if (res == null) {
  1052. return false;
  1053. }
  1054. var resData = res.data;
  1055. if (resData['code'] == 0) {
  1056. msg.transTag = 10; //已评价过
  1057. if (callback != null) {
  1058. callback();
  1059. }
  1060. SqlUtil().updateUserTranslateRate(msg.sessionId, msg.time, msg.transTag);
  1061. return true;
  1062. }
  1063. return false;
  1064. }
  1065. //根据经纬度获取用户国家城市
  1066. getAddress(double lon, double lat) async {
  1067. Map data = {
  1068. "lon": lon.toString(),
  1069. "lat": lat.toString(),
  1070. };
  1071. data['sign'] = TokenMgr().getSign(data);
  1072. data['language'] = UserData().language;
  1073. Response res = await HttpUtil().post('user/get/address', data: data);
  1074. if (res == null) return;
  1075. Map resData = res.data;
  1076. if (resData['code'] == 0 && resData['data'] != null) {
  1077. print(resData['data']);
  1078. List address = resData['data'].split(',');
  1079. if (address.length != 2) return;
  1080. String country = address[0];
  1081. String city = address[1];
  1082. UserData().isInChina = false;
  1083. if (country == '越南') {
  1084. UserData().currentCity = 'VietNam-';
  1085. List citys = constData[3]['city'][0]['List'];
  1086. for (int i = 0; i < citys.length; i++) {
  1087. if (citys[i]['Value'] == city) {
  1088. UserData().currentCity += citys[i]['Key'];
  1089. break;
  1090. }
  1091. }
  1092. } else if (country == '中国') {
  1093. UserData().isInChina = true;
  1094. UserData().currentCity = 'China-ChinaRepeat';
  1095. } else {
  1096. UserData().currentCity = 'VietNam-HoChiMinhCIty';
  1097. }
  1098. if (UserData().currentCity != UserData().basicInfo.meetPlace) {
  1099. UserData().basicInfo.meetPlace = UserData().currentCity;
  1100. changeCurrentCity(lon, lat, () {});
  1101. }
  1102. MessageMgr().emit('change_currentcity');
  1103. }
  1104. }
  1105. //根据经纬度获取用户国家城市
  1106. changeCurrentCity(double lon, double lat, callback) async {
  1107. if (UserData().basicInfo.userId == null) return;
  1108. Map data = {
  1109. "userId": UserData().basicInfo.userId,
  1110. "lon": lon.toString(),
  1111. "lat": lat.toString(),
  1112. };
  1113. data['sign'] = TokenMgr().getSign(data);
  1114. Response res = await HttpUtil().post('user/update/meetPlace', data: data);
  1115. if (res == null) return;
  1116. Map resData = res.data;
  1117. print(resData);
  1118. if (resData['code'] == 0) {
  1119. callback();
  1120. }
  1121. }
  1122. //通过手机号查询用户
  1123. searchNewFrindsByPhone(String phone, callback) async {
  1124. Map data = {
  1125. "userId": UserData().basicInfo.userId,
  1126. "value": phone,
  1127. };
  1128. data['sign'] = TokenMgr().getSign(data);
  1129. Response res = await HttpUtil()
  1130. .post('/friendship/search/userPhone', data: data, isShowLoading: true);
  1131. if (res == null) return;
  1132. Map resData = res.data;
  1133. print(resData);
  1134. if (resData['code'] == 0) {
  1135. callback(resData['data']['UserId']);
  1136. }
  1137. }
  1138. //拉黑用户
  1139. blackUser(int userId, callback) async {
  1140. Map data = {
  1141. "userid": UserData().basicInfo.userId,
  1142. "type": 1,
  1143. "followUserId": userId,
  1144. };
  1145. data['sign'] = TokenMgr().getSign(data);
  1146. Response res =
  1147. await HttpUtil().post('userfollow/follow/insert', data: data);
  1148. Map resData = res.data;
  1149. showToast(resData['msg']);
  1150. if (resData['code'] == 0) {
  1151. BlacklistMgr.addMyBlackList(userId);
  1152. callback();
  1153. }
  1154. }
  1155. //取消拉黑用户
  1156. cancleBlackUser(int userId, callback) async {
  1157. Map data = {
  1158. "userid": UserData().basicInfo.userId,
  1159. "type": 1,
  1160. "followUserId": userId,
  1161. };
  1162. data['sign'] = TokenMgr().getSign(data);
  1163. Response res = await HttpUtil()
  1164. .post('userfollow/follow/cancel', data: data, isShowLoading: true);
  1165. Map resData = res.data;
  1166. showToast(resData['msg']);
  1167. if (resData['code'] == 0) {
  1168. BlacklistMgr.removeMyBalckList(userId);
  1169. callback();
  1170. }
  1171. }
  1172. //收藏用户
  1173. setLove(int userId, callback) async {
  1174. Map data = {
  1175. "userid": UserData().basicInfo.userId,
  1176. "type": 0,
  1177. "followUserId": userId,
  1178. };
  1179. data['sign'] = TokenMgr().getSign(data);
  1180. Response res = await HttpUtil()
  1181. .post('userfollow/follow/insert', data: data, isShowLoading: true);
  1182. Map resData = res.data;
  1183. if (resData['code'] == 0) {
  1184. showToast(resData['msg']);
  1185. callback();
  1186. }
  1187. }
  1188. //取消收藏用户
  1189. cancleLove(int userId, callback) async {
  1190. Map data = {
  1191. "userid": UserData().basicInfo.userId,
  1192. "type": 0,
  1193. "followUserId": userId,
  1194. };
  1195. data['sign'] = TokenMgr().getSign(data);
  1196. Response res = await HttpUtil()
  1197. .post('userfollow/follow/cancel', data: data, isShowLoading: true);
  1198. Map resData = res.data;
  1199. if (resData['code'] == 0) {
  1200. showToast(resData['msg']);
  1201. callback();
  1202. }
  1203. }
  1204. //向企业服务助手提交信息
  1205. Future<bool> commitInfoToCompany(MsgModel msgModel) async {
  1206. Map data = {
  1207. "userid": msgModel.from,
  1208. "msgType": msgModel.msgType,
  1209. };
  1210. data['sign'] = TokenMgr().getSign(data);
  1211. data['msgContent'] = base64Encode(msgModel.msgContent);
  1212. msgModel.state = MsgState.Sending;
  1213. print('commitInfoToCompany 参数 $data');
  1214. Response res = await HttpUtil().post('feedback/user/insert', data: data);
  1215. if (res == null) {
  1216. msgModel.state = MsgState.SendingFailed;
  1217. ChatDataMgr().updateMsgState(msgModel.sessionId, msgModel.time,
  1218. msgModel.channelType, msgModel.state);
  1219. return false;
  1220. }
  1221. Map resData = res.data;
  1222. print('commitInfoToCompany $resData');
  1223. if (resData['code'] == 0) {
  1224. msgModel.state = MsgState.SendingSuccess;
  1225. ChatDataMgr().updateMsgState(msgModel.sessionId, msgModel.time,
  1226. msgModel.channelType, msgModel.state);
  1227. return true;
  1228. }
  1229. showToast(resData['msg']);
  1230. return false;
  1231. }
  1232. //焚阅照片恢复
  1233. resetPhoto(callback) async {
  1234. Map data = {
  1235. "userId": UserData().basicInfo.userId,
  1236. };
  1237. data['sign'] = TokenMgr().getSign(data);
  1238. Response res = await HttpUtil()
  1239. .post('user/recover/photos', data: data, isShowLoading: true);
  1240. Map resData = res.data;
  1241. if (resData['code'] == 0) {
  1242. showToast(resData['msg']);
  1243. callback();
  1244. }
  1245. }
  1246. //获取好友校验值
  1247. checkFriends() async {
  1248. Map data = {
  1249. "userId": UserData().basicInfo.userId,
  1250. };
  1251. data['sign'] = TokenMgr().getSign(data);
  1252. Response res = await HttpUtil()
  1253. .post('friendship/check/userFriends', data: data);
  1254. Map resData = res.data;
  1255. if (resData['code'] == 0) {
  1256. FriendListMgr().checkFromServer(resData['data']);
  1257. }
  1258. }
  1259. //保存设备名称和编码
  1260. saveMobileInfo() async {
  1261. String mobileType = '';
  1262. DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
  1263. if (Platform.isAndroid) {
  1264. AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
  1265. mobileType = androidInfo.model;
  1266. print('Running on ${androidInfo.model}'); // e.g. "Moto G (4)"
  1267. } else if (Platform.isIOS) {
  1268. IosDeviceInfo iosInfo = await deviceInfo.iosInfo;
  1269. mobileType = iosInfo.utsname.machine;
  1270. }
  1271. Map data = {
  1272. "userId": UserData().basicInfo.userId,
  1273. };
  1274. data['sign'] = TokenMgr().getSign(data);
  1275. data['model'] = mobileType;
  1276. data['coding'] = UserData().deviceLanguageCode;
  1277. Response res =
  1278. await HttpUtil().post('user/save/modelAndCoding', data: data);
  1279. Map resData = res.data;
  1280. print(resData);
  1281. }
  1282. }