Blame view

HDFwear/Mine/MineViewController.swift 41.3 KB
f2cf74c7   yangbin   1.0.20(4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
  //
  //  MineViewController.swift
  //  Twear
  //
  //  Created by yangbin on 2021/12/18.
  //
  
  import UIKit
  import MBProgressHUD
  import Alamofire
  import HandyJSON
  
  class MineViewController: UIViewController {
  
      @IBOutlet weak var tableView: UITableView!
      @IBOutlet weak var avatarImageView: UIImageView!
      @IBOutlet weak var idLabel: UILabel!
      @IBOutlet weak var nameLabel: UILabel!
      
875b68b4   daifengyi   feat:mine page UI
20
21
22
23
24
25
26
27
28
  //    @IBOutlet weak var medalNumLabel: UILabel!
  //    @IBOutlet weak var medalImageView1: UIImageView!
  //    @IBOutlet weak var medalImageView2: UIImageView!
  //    @IBOutlet weak var medalImageView3: UIImageView!
  //    @IBOutlet weak var medalImageView4: UIImageView!
  //    @IBOutlet weak var medalImageView5: UIImageView!
  //    @IBOutlet weak var locLabel1: UILabel!
      private let mineArray = ["健康报告", "我的数据", "个人资料", "隐私政策", "APP升级", "关于"]
      private let mineDic = ["健康报告": "health_report", "我的数据": "mine_data", "个人资料": "personal_info", "设置": "mine_setting", "APP升级": "app_update", "关于": "mine_about", "隐私政策": "privacy_policy"]
f2cf74c7   yangbin   1.0.20(4)
29
30
31
32
33
34
35
36
37
38
      
      private let user = UserInfo
  
      override func viewWillAppear(_ animated: Bool) {
          super.viewWillAppear(animated)
          self.navigationController?.setNavigationBarHidden(false, animated: true)
      }
      
      override func viewDidLoad() {
          super.viewDidLoad()
0f975482   jason   feat:exercise
39
          BluetoothManager.shared.registerSyncDelegate(self)
f2cf74c7   yangbin   1.0.20(4)
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
          setupUI()
  
  
      }
      
      private func setupUI() {
          let leftButton = UIButton(frame: CGRect(x: 0, y: 0, width: 40, height: 28))
          leftButton.setTitle(LocString("我的"), for: .normal)
          leftButton.titleLabel?.font = BoldFont(18)
          leftButton.setTitleColor(.black, for: .normal)
          navigationItem.leftBarButtonItem = UIBarButtonItem(customView: leftButton)
          
          tableView.bounces = false
          
          if let image = UIImage.getImageFromPath("avatar") {
              avatarImageView.image = image
          } else {
              avatarImageView.image = UIImage(named: user.gender == 1 ? "avatar_male" : "avatar_female")
          }
          
          if user.name == "" {
f2624318   daifengyi   feat:rename throu...
61
              nameLabel.text = "YTWatch"//"\(LocString("用户"))\(user.userId)"
f2cf74c7   yangbin   1.0.20(4)
62
63
64
65
          } else {
              nameLabel.text = user.name
          }
          
875b68b4   daifengyi   feat:mine page UI
66
          idLabel.text = "\(user.gender == 1 ? "男" : "女") \(user.height)cm"
f2cf74c7   yangbin   1.0.20(4)
67
          
875b68b4   daifengyi   feat:mine page UI
68
  //        locLabel1.text = LocString("我的勋章")
f2cf74c7   yangbin   1.0.20(4)
69
          
875b68b4   daifengyi   feat:mine page UI
70
71
72
73
74
75
76
77
78
79
80
81
82
83
  //        var medalArray = ["单日10000步灰", "单日10000步灰", "单日10000步灰", "累计5万步灰", "累计10万步灰"]
  //        var medalNum: Int = 0
  //        if let array = RealmTools.objectsWithPredicateAndSorted(object: MedalModel.self, predicate: NSPredicate(format: "date != nil"), sortedKey: "date") as? Array<MedalModel>, array.count > 0 {
  //            medalNum = array.count
  //            for medal in array {
  //                medalArray.insert(medal.title, at: 0)
  //            }
  //        }
  //        medalNumLabel.text = LocString("共1") + "\(medalNum)" + LocString("枚1")
  //        medalImageView1.image = UIImage(named: medalArray[0])
  //        medalImageView2.image = UIImage(named: medalArray[1])
  //        medalImageView3.image = UIImage(named: medalArray[2])
  //        medalImageView4.image = UIImage(named: medalArray[3])
  //        medalImageView5.image = UIImage(named: medalArray[4])
f2cf74c7   yangbin   1.0.20(4)
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
        
      }
      
      @IBAction func setUserInfo(_ sender: Any) {
          let vc = UIStoryboard.loadViewControllerIdentifier(storyboardName: "Mine", identifier: "UserInfoSettingVC") as! UserInfoSettingVC
          vc.modifyClosure = {[weak self] name, image in
              if image != nil {
                  self?.avatarImageView.image = image
              }
              if name != "" {
                  self?.nameLabel.text = name
              }
              
          }
          navigationController?.pushViewController(vc, animated: true)
      }
      
      @IBAction func gotoMedalVC(_ sender: Any) {
          let vc = UIStoryboard.loadViewControllerIdentifier(storyboardName: "Mine", identifier: "MedalViewController") as! MedalViewController
          navigationController?.pushViewController(vc, animated: true)
      }
      
      func checkAppVersion() {
          MBProgressHUD.showLoading(LocString("正在拼命加载..."), icon: "loading_icon")
          let infoDictionary : Dictionary = Bundle.main.infoDictionary!
          let curVersion = infoDictionary["CFBundleShortVersionString"] as? String
          let path = "https://itunes.apple.com/cn/lookup?id=1601611643"//
          var version: String = ""
          Alamofire.request(path, method: .post).response { (responseObj) in
              if responseObj.error == nil {
                  let dic:Dictionary = try! JSONSerialization.jsonObject(with: responseObj.data!, options: JSONSerialization.ReadingOptions.mutableContainers) as! Dictionary<String,Any>
                  if  dic["resultCount"] as! Int > 0{
                      let results:Array = dic["results"] as! Array<Any>
                      if results.count > 0 {
                          let resultsDic: Dictionary = results.first as! Dictionary<String,Any>
                          version = resultsDic["version"] as! String
  //                        let size = resultsDic["fileSizeBytes"] as! Int
                          let releaseNotes = resultsDic["releaseNotes"] as? String ?? "   "
                          let trackViewUrl = resultsDic["trackViewUrl"] as! String
                          if curVersion!.checkVersion(version) { //发现新版本
                              MBProgressHUD.hide()
                              let updateView = AppVersionView(version: version, detail: releaseNotes)
                              updateView.clickClosure = { [weak self] in
                                  self?.gotoAppStore(trackViewUrl)
                              }
                              
                              updateView.show()
                          } else {
                              MBProgressHUD.hide()
                              MBProgressHUD.showh(LocString("当前已是最新版本"))
                          }
                      }
                  }
              }
          }
      }
      
  
      
      
      func gotoAppStore(_ urlString: String) {
          let updateUrl: URL = URL(string: urlString)!
          if #available(iOS 10.0, *) {
              UIApplication.shared.open(updateUrl, options: [:], completionHandler: nil)
          } else {
              UIApplication.shared.openURL(updateUrl)
          }
      }
      
      deinit {
          print("deinit\(NSStringFromClass(type(of: self)))!!!!!!!")
      }
  
  }
  
  
  extension MineViewController: UITableViewDataSource, UITableViewDelegate {
      func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
875b68b4   daifengyi   feat:mine page UI
162
          return 62
f2cf74c7   yangbin   1.0.20(4)
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
      }
      func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
          return mineArray.count
      }
      func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
          let cell = tableView.dequeueReusableCell(withIdentifier: "MineCell", for: indexPath) as! MineCell
          cell.label.text = LocString(mineArray[indexPath.row])
          cell.setImageView.image = UIImage(named: mineDic[mineArray[indexPath.row]]!)
          if indexPath.row == mineArray.count-1 {
              cell.lineView.isHidden = true
          }
          return cell
      }
      
      func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
          switch mineArray[indexPath.row] {
875b68b4   daifengyi   feat:mine page UI
179
          case "APP升级":
f2cf74c7   yangbin   1.0.20(4)
180
181
182
183
184
185
186
187
188
              checkAppVersion()
          case "个人资料":
              let vc = UIStoryboard.loadViewControllerIdentifier(storyboardName: "Mine", identifier: "UserInfoSettingVC") as! UserInfoSettingVC
              vc.modifyClosure = {[weak self] name, image in
                  self?.avatarImageView.image = image
                  self?.nameLabel.text = name
              }
              navigationController?.pushViewController(vc, animated: true)
          case "关于":
156c1ec4   daifengyi   feat:debug alert
189
190
191
192
              //jtd!
  //            let vc = UIStoryboard.loadViewControllerIdentifier(storyboardName: "Mine", identifier: "AboutAppVC")
  //            navigationController?.pushViewController(vc, animated: true)
              let alert = UIAlertController(title: "plz select", message: nil, preferredStyle: .actionSheet)
66e40f13   jason   feat: blood oxyge...
193
194
195
196
197
              
              let archiveAction0 = UIAlertAction(title: "Fetch Date", style: .default) { action in
                  self.fetchDataAlert()
              }
              
156c1ec4   daifengyi   feat:debug alert
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
              let archiveAction1 = UIAlertAction(title: "newSetTouchSense", style: .default) { action in
                  BluetoothManager.shared.newSetTouchSense(bool: true) { error in
                      if error != nil {
                          print("newSetTouchSense" + (error?.description ?? "") )
                      }else {
                          print("newSetTouchSense success")
                      }
                  }
              }
              let archiveAction2 = UIAlertAction(title: "newSetLowPowerRemind", style: .default) { action in
                  BluetoothManager.shared.newSetLowPowerRemind(bool: true) { error in
                      if error != nil {
                          print("newSetLowPowerRemind" + (error?.description ?? ""))
                      }else {
                          print("newSetLowPowerRemind success")
                      }
                  }
              }
              let archiveAction3 = UIAlertAction(title: "newSetRestore", style: .default) { action in
                  BluetoothManager.shared.newSetRestore() { error in
                      if error != nil {
                          print("newSetRestore" + (error?.description ?? ""))
                      }else {
                          print("newSetRestore success")
                      }
                  }
              }
              let archiveAction4 = UIAlertAction(title: "newSetHeartRateHighRemind", style: .default) { action in
                  BluetoothManager.shared.newSetHeartRateHighRemind(maxHr: 120) { error in
                      if error != nil {
                          print("newSetHeartRateHighRemind" + (error?.description ?? ""))
                      }else {
                          print("newSetHeartRateHighRemind success")
                      }
                  }
              }
              let archiveAction5 = UIAlertAction(title: "newSetHeartRateLowRemind", style: .default) { action in
                  BluetoothManager.shared.newSetHeartRateLowRemind(minHr: 120) { error in
                      if error != nil {
                          print("newSetHeartRateLowRemind" + (error?.description ?? ""))
                      }else {
                          print("newSetHeartRateLowRemind success")
                      }
                  }
              }
              let archiveAction6 = UIAlertAction(title: "newSetPressureAutoDetect", style: .default) { action in
                  BluetoothManager.shared.newSetPressureAutoDetect(bool: true) { error in
                      if error != nil {
                          print("newSetPressureAutoDetect" + (error?.description ?? ""))
                      }else {
                          print("newSetPressureAutoDetect success")
                      }
                  }
              }
a21b612e   jason   feat:closure setup
252
              let archiveAction7a = UIAlertAction(title: "newSetBloodOxygenAutoDetect enable", style: .default) { action in
156c1ec4   daifengyi   feat:debug alert
253
254
255
256
257
258
259
260
                  BluetoothManager.shared.newSetBloodOxygenAutoDetect(bool: true) { error in
                      if error != nil {
                          print("newSetBloodOxygenAutoDetect" + (error?.description ?? ""))
                      }else {
                          print("newSetBloodOxygenAutoDetect success")
                      }
                  }
              }
a21b612e   jason   feat:closure setup
261
262
263
264
265
266
267
268
269
              let archiveAction7b = UIAlertAction(title: "newSetBloodOxygenAutoDetect disable", style: .default) { action in
                  BluetoothManager.shared.newSetBloodOxygenAutoDetect(bool: false) { error in
                      if error != nil {
                          print("newSetBloodOxygenAutoDetect" + (error?.description ?? ""))
                      }else {
                          print("newSetBloodOxygenAutoDetect success")
                      }
                  }
              }
156c1ec4   daifengyi   feat:debug alert
270
271
272
273
274
275
276
277
278
              let archiveAction8 = UIAlertAction(title: "newSetUserInfo", style: .default) { action in
                  BluetoothManager.shared.newSetUserInfo(AdminHelper.shared.loadLocalAdminData().userInfo) { error in
                      if error != nil {
                          print("newSetUserInfo" + (error?.description ?? ""))
                      }else {
                          print("newSetUserInfo success")
                      }
                  }
              }
156c1ec4   daifengyi   feat:debug alert
279
              
69e5b680   daifengyi   feat:query device...
280
281
282
283
284
285
286
287
288
289
              let archiveAction11 = UIAlertAction(title: "queryDeviceInfo", style: .default) { action in
                  BluetoothManager.shared.queryDeviceInfo(queryItems: [0x02,0x03]) { error in
                      if error != nil {
                          print("queryDeviceInfo" + (error?.description ?? ""))
                      }else {
                          print("queryDeviceInfo success")
                      }
                  }
              }
              
949f38df   daifengyi   feat:not disturb
290
              let archiveAction12 = UIAlertAction(title: "newSetNotDisturb", style: .default) { action in
02bd7bf8   jason   feat:no disturb
291
292
293
294
295
296
297
                  let noDisturb = NewNoDisturbModel()
                  noDisturb.enable = true
                  noDisturb.startHour = 8
                  noDisturb.startMinute = 30
                  noDisturb.endHour = 15
                  noDisturb.endMinute = 45
                  BluetoothManager.shared.newSetNotDisturb(noDisturb: noDisturb) { error in
949f38df   daifengyi   feat:not disturb
298
299
300
301
302
303
304
305
                      if error != nil {
                          print("newSetNotDisturb" + (error?.description ?? ""))
                      }else {
                          print("newSetNotDisturb success")
                      }
                  }
              }
              
f13858d1   daifengyi   feat:read me
306
307
308
309
310
311
312
313
314
315
              let archiveAction13 = UIAlertAction(title: "newSetFindWatch", style: .default) { action in
                  BluetoothManager.shared.newSetFindWatch(bool: true) { error in
                      if error != nil {
                          print("newSetFindWatch" + (error?.description ?? ""))
                      }else {
                          print("newSetFindWatch success")
                      }
                  }
              }
              
9b19e727   jason   feat:new set time...
316
317
318
319
320
321
322
323
324
              let archiveAction18 = UIAlertAction(title: "newSetTime", style: .default) { action in
                  BluetoothManager.shared.newSetTime { error in
                      if error != nil {
                          print("newSetTime" + (error?.description ?? ""))
                      }else {
                          print("newSetTime success")
                      }
                  }
              }
f13858d1   daifengyi   feat:read me
325
              
b05829d0   jason   feat:set weather
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
              let archiveAction19 = UIAlertAction(title: "newSetWeather", style: .default) { action in
                  let next5day = [NewNextWeatherModel(highestTemperature: 21, lowestTemperature: 11, type: .sunny),
                                  NewNextWeatherModel(highestTemperature: 22, lowestTemperature: 12, type: .sunny),
                                  NewNextWeatherModel(highestTemperature: 23, lowestTemperature: 13, type: .sunny),
                                  NewNextWeatherModel(highestTemperature: 24, lowestTemperature: 14, type: .sunny),
                                  NewNextWeatherModel(highestTemperature: 25, lowestTemperature: 15, type: .sunny)
                  ]
                  let weather = NewWeatherModel(currentTemperature: 18, highestTemperature: 20, lowestTemperature: 10, type: .cloudy, airQuality: .moderate, humidity: 3, wind: .northeast, windForce: 4, next5Days: next5day, position: "长沙")
                  BluetoothManager.shared.newSetWeather(weather: weather) { error in
                      if error != nil {
                          print("newSetWeather" + (error?.description ?? ""))
                      }else {
                          print("newSetWeather success")
                      }
                  }
              }
              
9b1c370b   jason   feat:beidou
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
              let archiveAction20 = UIAlertAction(title: "newSetBeiDouContact", style: .default) { action in
                  let contacts = [NewBeiDouContactModel(name: "周杰伦", phone: "18974960001", type: .emergency),
                                  NewBeiDouContactModel(name: "梁朝伟", phone: "18974960002", type: .general),
                                  NewBeiDouContactModel(name: "吴彦祖", phone: "18974960003", type: .emergency),
                                  NewBeiDouContactModel(name: "成龙", phone: "18974960004", type: .general)]
                  BluetoothManager.shared.newSetBeiDouContact(contacts: contacts) { error in
                      if error != nil {
                          print("newSetBeiDouContact" + (error?.description ?? ""))
                      }else {
                          print("newSetBeiDouContact success")
                      }
                  }
              }
              
              let archiveAction21 = UIAlertAction(title: "newSetBeiDouQuickAnswer", style: .default) { action in
                  BluetoothManager.shared.newSetBeiDouQuickAnswer(answers: ["北斗"]) { error in
                      if error != nil {
                          print("newSetBeiDouQuickAnswer" + (error?.description ?? ""))
                      }else {
                          print("newSetBeiDouQuickAnswer success")
                      }
                  }
              }
              
c7f49054   jason   feat: rest & exer...
367
368
369
370
371
372
373
374
375
376
              let archiveAction23 = UIAlertAction(title: "newSetRestHeartRateRemind", style: .default) { action in
                  BluetoothManager.shared.newSetRestHeartRateRemind(bool: true, minHr: 60, maxHr: 90) { error in
                      if error != nil {
                          print("newSetRestHeartRateRemind" + (error?.description ?? ""))
                      }else {
                          print("newSetRestHeartRateRemind success")
                      }
                  }
              }
              
4239cb3b   jason   feat:exercise hr ...
377
378
379
380
381
382
383
384
385
386
387
              let archiveAction24a = UIAlertAction(title: "newSetExerciseHeartRateRemind disable", style: .default) { action in
                  BluetoothManager.shared.newSetExerciseHeartRateRemind(bool: false, minHr: 60, maxHr: 90) { error in
                      if error != nil {
                          print("newSetExerciseHeartRateRemind" + (error?.description ?? ""))
                      }else {
                          print("newSetExerciseHeartRateRemind success")
                      }
                  }
              }
              
              let archiveAction24b = UIAlertAction(title: "newSetExerciseHeartRateRemind enable 110-150", style: .default) { action in
c7f49054   jason   feat: rest & exer...
388
389
390
391
392
393
394
395
396
                  BluetoothManager.shared.newSetExerciseHeartRateRemind(bool: true, minHr: 110, maxHr: 150) { error in
                      if error != nil {
                          print("newSetExerciseHeartRateRemind" + (error?.description ?? ""))
                      }else {
                          print("newSetExerciseHeartRateRemind success")
                      }
                  }
              }
              
b74ad0a2   jason   feat:bo remind & ...
397
398
399
400
401
402
403
404
405
406
407
              let archiveAction25a = UIAlertAction(title: "newSetHeartRateDetectInterval disable", style: .default) { action in
                  BluetoothManager.shared.newSetHeartRateDetectInterval(bool: false, interval: 30) { error in
                      if error != nil {
                          print("newSetHeartRateDetectInterval" + (error?.description ?? ""))
                      }else {
                          print("newSetHeartRateDetectInterval success")
                      }
                  }
              }
              
              let archiveAction25b = UIAlertAction(title: "newSetHeartRateDetectInterval enable 18", style: .default) { action in
03cac185   jason   feat:heart rate d...
408
409
410
411
412
413
414
415
416
                  BluetoothManager.shared.newSetHeartRateDetectInterval(bool: true, interval: 18) { error in
                      if error != nil {
                          print("newSetHeartRateDetectInterval" + (error?.description ?? ""))
                      }else {
                          print("newSetHeartRateDetectInterval success")
                      }
                  }
              }
              
b74ad0a2   jason   feat:bo remind & ...
417
418
419
420
421
422
423
424
425
426
427
              let archiveAction26a = UIAlertAction(title: "newSetBloodOxygenLowRemind disable", style: .default) { action in
                  BluetoothManager.shared.newSetBloodOxygenLowRemind(minBo: 0) { error in
                      if error != nil {
                          print("newSetBloodOxygenLowRemind" + (error?.description ?? ""))
                      }else {
                          print("newSetBloodOxygenLowRemind success")
                      }
                  }
              }
              
              let archiveAction26b = UIAlertAction(title: "newSetBloodOxygenLowRemind enable 80", style: .default) { action in
a9f41925   jason   feat:blood oxygen...
428
429
430
431
432
433
434
435
436
                  BluetoothManager.shared.newSetBloodOxygenLowRemind(minBo: 80) { error in
                      if error != nil {
                          print("newSetBloodOxygenLowRemind" + (error?.description ?? ""))
                      }else {
                          print("newSetBloodOxygenLowRemind success")
                      }
                  }
              }
              
5caab734   jason   feat:message remind
437
438
439
440
441
442
443
444
445
              let archiveAction27 = UIAlertAction(title: "newSetMessageRemind", style: .default) { action in
                  BluetoothManager.shared.newSetMessageRemind(enable: true, system: true, wechat: false, qq: false) { error in
                      if error != nil {
                          print("newSetMessageRemind" + (error?.description ?? ""))
                      }else {
                          print("newSetMessageRemind success")
                      }
                  }
              }
a9f41925   jason   feat:blood oxygen...
446
              
0f975482   jason   feat:exercise
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
              let archiveAction28a = UIAlertAction(title: "newSetExerciseStatus 1", style: .default) { action in
                  BluetoothManager.shared.newSetExerciseStatus(status: 1, type: 0) { error in
                      if error != nil {
                          print("newSetExerciseStatus" + (error?.description ?? ""))
                      }else {
                          print("newSetExerciseStatus success")
                      }
                  }
              }
              
              let archiveAction28b = UIAlertAction(title: "newSetExerciseStatus 6", style: .default) { action in
                  BluetoothManager.shared.newSetExerciseStatus(status: 6, type: 0) { error in
                      if error != nil {
                          print("newSetExerciseStatus" + (error?.description ?? ""))
                      }else {
                          print("newSetExerciseStatus success")
                      }
                  }
              }
              
              let archiveAction28c = UIAlertAction(title: "newSetExerciseStatus 7", style: .default) { action in
                  BluetoothManager.shared.newSetExerciseStatus(status: 7, type: 0) { error in
                      if error != nil {
                          print("newSetExerciseStatus" + (error?.description ?? ""))
                      }else {
                          print("newSetExerciseStatus success")
                      }
                  }
              }
              
d984b16d   jason   feat:set exercise...
477
478
479
480
481
482
483
484
485
486
              let archiveAction28d = UIAlertAction(title: "newSetExerciseStatus 5", style: .default) { action in
                  BluetoothManager.shared.newSetExerciseStatus(status: 5, type: 0) { error in
                      if error != nil {
                          print("newSetExerciseStatus" + (error?.description ?? ""))
                      }else {
                          print("newSetExerciseStatus success")
                      }
                  }
              }
              
a21b612e   jason   feat:closure setup
487
              let archiveAction29a = UIAlertAction(title: "newSetWristSense enable", style: .default) { action in
728a0182   jason   feat:wrist sense
488
489
490
491
492
493
494
495
496
                  BluetoothManager.shared.newSetWristSense(bool: true) { error in
                      if error != nil {
                          print("newSetWristSense" + (error?.description ?? ""))
                      }else {
                          print("newSetWristSense success")
                      }
                  }
              }
              
a21b612e   jason   feat:closure setup
497
498
499
500
501
502
503
504
505
506
              let archiveAction29b = UIAlertAction(title: "newSetWristSense disable", style: .default) { action in
                  BluetoothManager.shared.newSetWristSense(bool: false) { error in
                      if error != nil {
                          print("newSetWristSense" + (error?.description ?? ""))
                      }else {
                          print("newSetWristSense success")
                      }
                  }
              }
              
728a0182   jason   feat:wrist sense
507
              let archiveAction88 = UIAlertAction(title: "ota update", style: .default) { action in
60a29b2c   jason   feat:ota viewcont...
508
509
510
                  BluetoothManager.shared.startOtaUpdate()
              }
              
66e40f13   jason   feat: blood oxyge...
511
              alert.addAction(archiveAction0)
156c1ec4   daifengyi   feat:debug alert
512
513
514
515
516
517
              alert.addAction(archiveAction1)
              alert.addAction(archiveAction2)
              alert.addAction(archiveAction3)
              alert.addAction(archiveAction4)
              alert.addAction(archiveAction5)
              alert.addAction(archiveAction6)
a21b612e   jason   feat:closure setup
518
519
              alert.addAction(archiveAction7a)
              alert.addAction(archiveAction7b)
156c1ec4   daifengyi   feat:debug alert
520
              alert.addAction(archiveAction8)
66e40f13   jason   feat: blood oxyge...
521
              
69e5b680   daifengyi   feat:query device...
522
              alert.addAction(archiveAction11)
949f38df   daifengyi   feat:not disturb
523
              alert.addAction(archiveAction12)
f13858d1   daifengyi   feat:read me
524
              alert.addAction(archiveAction13)
66e40f13   jason   feat: blood oxyge...
525
  
9b19e727   jason   feat:new set time...
526
              alert.addAction(archiveAction18)
b05829d0   jason   feat:set weather
527
              alert.addAction(archiveAction19)
9b1c370b   jason   feat:beidou
528
529
              alert.addAction(archiveAction20)
              alert.addAction(archiveAction21)
66e40f13   jason   feat: blood oxyge...
530
              
c7f49054   jason   feat: rest & exer...
531
              alert.addAction(archiveAction23)
4239cb3b   jason   feat:exercise hr ...
532
533
              alert.addAction(archiveAction24a)
              alert.addAction(archiveAction24b)
b74ad0a2   jason   feat:bo remind & ...
534
535
536
537
              alert.addAction(archiveAction25a)
              alert.addAction(archiveAction25b)
              alert.addAction(archiveAction26a)
              alert.addAction(archiveAction26b)
5caab734   jason   feat:message remind
538
              alert.addAction(archiveAction27)
0f975482   jason   feat:exercise
539
              alert.addAction(archiveAction28a)
d984b16d   jason   feat:set exercise...
540
              alert.addAction(archiveAction28d)
0f975482   jason   feat:exercise
541
542
              alert.addAction(archiveAction28b)
              alert.addAction(archiveAction28c)
a21b612e   jason   feat:closure setup
543
544
              alert.addAction(archiveAction29a)
              alert.addAction(archiveAction29b)
728a0182   jason   feat:wrist sense
545
              alert.addAction(archiveAction88)
9b1c370b   jason   feat:beidou
546
              
c7f49054   jason   feat: rest & exer...
547
              alert.addAction(UIAlertAction(title: "取消", style: .destructive, handler: nil))
156c1ec4   daifengyi   feat:debug alert
548
              present(alert, animated: true, completion: nil)
f2cf74c7   yangbin   1.0.20(4)
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
          case "我的数据":
              let vc = UIStoryboard.loadViewControllerIdentifier(storyboardName: "Mine", identifier: "HealthDataVC")
              navigationController?.pushViewController(vc, animated: true)
          case "健康报告":
              let vc = UIStoryboard.loadViewControllerIdentifier(storyboardName: "Mine", identifier: "HealthReportVC")
              navigationController?.pushViewController(vc, animated: true)
          case "隐私政策":
              let vc = UIStoryboard.loadViewControllerIdentifier(storyboardName: "Mine", identifier: "PrivacyViewController")
              navigationController?.pushViewController(vc, animated: true)
              
          default:
              break
          }
      }
      
66e40f13   jason   feat: blood oxyge...
564
565
566
      func fetchDataAlert () {
          let alert = UIAlertController(title: "plz select fetch type", message: nil, preferredStyle: .actionSheet)
          
a833b1ce   jason   feat:sleep now & ...
567
568
          let archiveAction9a = UIAlertAction(title: "getSleepData now", style: .default) {[weak self] action in
              BluetoothManager.shared.getSleepData(option: .now) { sleepModel, error in
66e40f13   jason   feat: blood oxyge...
569
                  if error != nil {
a833b1ce   jason   feat:sleep now & ...
570
                      print("getSleepData" + (error?.description ?? ""))
66e40f13   jason   feat: blood oxyge...
571
                  }else {
cdaa3f52   jason   feat:log alert
572
                      self?.showDetailAlert(msg: sleepModel?.description)
a833b1ce   jason   feat:sleep now & ...
573
574
575
576
577
578
579
580
581
582
583
                      print("getSleepData success")
                  }
              }
          }
          let archiveAction9b = UIAlertAction(title: "getSleepData history", style: .default) {[weak self] action in
              BluetoothManager.shared.getSleepData(option: .history) { sleepModel, error in
                  if error != nil {
                      print("getSleepData" + (error?.description ?? ""))
                  }else {
                      self?.showDetailAlert(msg: sleepModel?.description)
                      print("getSleepData success")
66e40f13   jason   feat: blood oxyge...
584
585
586
                  }
              }
          }
737bea72   jason   feat:blood oxygen...
587
588
          let archiveAction10a = UIAlertAction(title: "getBloodOxygenData now", style: .default) {[weak self] action in
              BluetoothManager.shared.getBloodOxygenData(option: .now) { boArray, error in
66e40f13   jason   feat: blood oxyge...
589
                  if error != nil {
737bea72   jason   feat:blood oxygen...
590
                      print("getBloodOxygenData" + (error?.description ?? ""))
66e40f13   jason   feat: blood oxyge...
591
                  }else {
cdaa3f52   jason   feat:log alert
592
                      self?.showDetailAlert(msg: boArray.description)
737bea72   jason   feat:blood oxygen...
593
                      print("getBloodOxygenData success")
66e40f13   jason   feat: blood oxyge...
594
595
596
                  }
              }
          }
737bea72   jason   feat:blood oxygen...
597
598
599
600
601
602
603
604
605
606
607
          let archiveAction10b = UIAlertAction(title: "getBloodOxygenData history", style: .default) {[weak self] action in
              BluetoothManager.shared.getBloodOxygenData(option: .history) { boArray, error in
                  if error != nil {
                      print("getBloodOxygenData" + (error?.description ?? ""))
                  }else {
                      self?.showDetailAlert(msg: boArray.description)
                      print("getBloodOxygenData success")
                  }
              }
          }
          
66e40f13   jason   feat: blood oxyge...
608
          
191ca3ba   jason   feat:heart rate n...
609
610
          let archiveAction14a = UIAlertAction(title: "getHeartRateData now", style: .default) {[weak self] action in
              BluetoothManager.shared.getHeartRateData(option: .now) { hrArray, error in
66e40f13   jason   feat: blood oxyge...
611
                  if error != nil {
191ca3ba   jason   feat:heart rate n...
612
                      print("getHeartRateData" + (error?.description ?? ""))
66e40f13   jason   feat: blood oxyge...
613
                  }else {
cdaa3f52   jason   feat:log alert
614
                      self?.showDetailAlert(msg: hrArray.description)
191ca3ba   jason   feat:heart rate n...
615
616
617
618
619
620
621
622
623
624
625
                      print("getHeartRateData success")
                  }
              }
          }
          let archiveAction14b = UIAlertAction(title: "getHeartRateData history", style: .default) {[weak self] action in
              BluetoothManager.shared.getHeartRateData(option: .history) { hrArray, error in
                  if error != nil {
                      print("getHeartRateData" + (error?.description ?? ""))
                  }else {
                      self?.showDetailAlert(msg: hrArray.description)
                      print("getHeartRateData success")
66e40f13   jason   feat: blood oxyge...
626
627
628
629
                  }
              }
          }
          
6e1c7072   jason   feat:step now & h...
630
631
          let archiveAction15a = UIAlertAction(title: "getStepData now", style: .default) {[weak self] action in
              BluetoothManager.shared.getStepData(option: .now) { sArray, error in
66e40f13   jason   feat: blood oxyge...
632
                  if error != nil {
6e1c7072   jason   feat:step now & h...
633
                      print("getStepData" + (error?.description ?? ""))
66e40f13   jason   feat: blood oxyge...
634
                  }else {
cdaa3f52   jason   feat:log alert
635
                      self?.showDetailAlert(msg: sArray.description)
6e1c7072   jason   feat:step now & h...
636
637
638
639
640
641
642
643
644
645
646
                      print("getStepData success")
                  }
              }
          }
          let archiveAction15b = UIAlertAction(title: "getStepData history", style: .default) {[weak self] action in
              BluetoothManager.shared.getStepData(option: .history) { sArray, error in
                  if error != nil {
                      print("getStepData" + (error?.description ?? ""))
                  }else {
                      self?.showDetailAlert(msg: sArray.description)
                      print("getStepData success")
66e40f13   jason   feat: blood oxyge...
647
648
649
650
                  }
              }
          }
          
6e1c7072   jason   feat:step now & h...
651
652
653
654
655
656
657
658
659
660
661
662
          let archiveAction17a = UIAlertAction(title: "getPressureData now", style: .default) {[weak self] action in
              BluetoothManager.shared.getPressureData(option: .now) { pArray, error in
                  if error != nil {
                      print("getPressureData" + (error?.description ?? ""))
                  }else {
                      self?.showDetailAlert(msg: pArray.description)
                      print("getPressureData success")
                  }
              }
          }
          let archiveAction17b = UIAlertAction(title: "getPressureData history", style: .default) {[weak self] action in
              BluetoothManager.shared.getPressureData(option: .history) { pArray, error in
66e40f13   jason   feat: blood oxyge...
663
                  if error != nil {
6e1c7072   jason   feat:step now & h...
664
                      print("getPressureData" + (error?.description ?? ""))
66e40f13   jason   feat: blood oxyge...
665
                  }else {
cdaa3f52   jason   feat:log alert
666
                      self?.showDetailAlert(msg: pArray.description)
6e1c7072   jason   feat:step now & h...
667
                      print("getPressureData success")
66e40f13   jason   feat: blood oxyge...
668
669
670
671
672
673
674
675
676
677
678
679
680
681
                  }
              }
          }
          
          let archiveAction22 = UIAlertAction(title: "newGetBatteryData", style: .default) { action in
              BluetoothManager.shared.newGetBatteryData { error in
                  if error != nil {
                      print("newGetBatteryData" + (error?.description ?? ""))
                  }else {
                      print("newGetBatteryData success")
                  }
              }
          }
          
6e0a8d81   jason   feat:gps now & hi...
682
683
684
685
686
687
688
689
690
691
692
693
          let archiveAction101a = UIAlertAction(title: "newGetGpsData now", style: .default) {[weak self] action in
              BluetoothManager.shared.newGetGpsData(option: .now) {gpsModel, error in
                  if error != nil {
                      print("newGetGpsData" + (error?.description ?? ""))
                  }else {
                      self?.showDetailAlert(msg: gpsModel?.description)
                      print("newGetGpsData success")
                  }
              }
          }
          let archiveAction101b = UIAlertAction(title: "newGetGpsData history", style: .default) {[weak self] action in
              BluetoothManager.shared.newGetGpsData(option: .history) {gpsModel, error in
66e40f13   jason   feat: blood oxyge...
694
695
696
                  if error != nil {
                      print("newGetGpsData" + (error?.description ?? ""))
                  }else {
cdaa3f52   jason   feat:log alert
697
                      self?.showDetailAlert(msg: gpsModel?.description)
66e40f13   jason   feat: blood oxyge...
698
699
700
701
702
                      print("newGetGpsData success")
                  }
              }
          }
          
36b76cd7   jason   feat:intensive ti...
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
          let archiveAction102a = UIAlertAction(title: "newGetIntensiveTimeData now", style: .default) {[weak self] action in
              BluetoothManager.shared.newGetIntensiveTimeData(option: .now) {intensiveTimeModel, error in
                  if error != nil {
                      print("newGetIntensiveTimeData" + (error?.description ?? ""))
                  }else {
                      self?.showDetailAlert(msg: intensiveTimeModel?.description)
                      print("newGetIntensiveTimeData success")
                  }
              }
          }
          let archiveAction102b = UIAlertAction(title: "newGetIntensiveTimeData history", style: .default) {[weak self] action in
              BluetoothManager.shared.newGetIntensiveTimeData(option: .history) {intensiveTimeModel, error in
                  if error != nil {
                      print("newGetIntensiveTimeData" + (error?.description ?? ""))
                  }else {
                      self?.showDetailAlert(msg: intensiveTimeModel?.description)
                      print("newGetIntensiveTimeData success")
                  }
              }
          }
          
6a02f533   jason   feat:beidou card
724
725
726
727
728
729
730
731
732
733
          let archiveAction103 = UIAlertAction(title: "newGetBeidouCardData", style: .default) {[weak self] action in
              BluetoothManager.shared.newGetBeidouCardData() {card, error in
                  if error != nil {
                      print("newGetBeidouCardData" + (error?.description ?? ""))
                  }else {
                      self?.showDetailAlert(msg: card)
                      print("newGetBeidouCardData success")
                  }
              }
          }
66e40f13   jason   feat: blood oxyge...
734
          
b867ff0e   jason   feat:fetch exerci...
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
          let archiveAction104a = UIAlertAction(title: "getExerciseData now", style: .default) {[weak self] action in
              BluetoothManager.shared.getExerciseData() {exerciseModel, error in
                  if error != nil {
                      print("getExerciseData" + (error?.description ?? ""))
                  }else {
  //                    self?.showDetailAlert(msg: card)
                      print("getExerciseData success")
                  }
              }
          }
          let archiveAction104b = UIAlertAction(title: "getExerciseData history", style: .default) {[weak self] action in
              BluetoothManager.shared.getExerciseData(option: .history) {exerciseModel, error in
                  if error != nil {
                      print("getExerciseData" + (error?.description ?? ""))
                  }else {
  //                    self?.showDetailAlert(msg: card)
                      print("getExerciseData success")
                  }
              }
          }
          
40bc8724   jason   feat:firmware ver...
756
757
758
759
760
761
762
763
764
765
766
          let archiveAction105 = UIAlertAction(title: "newGetfirmwareVersionData", style: .default) {[weak self] action in
              BluetoothManager.shared.newGetfirmwareVersionData() {first, second, error in
                  if error != nil {
                      print("newGetfirmwareVersionData" + (error?.description ?? ""))
                  }else {
                      self?.showDetailAlert(msg: "first is" + String(first ?? 0) + "\nsecond is " + String(second ?? 0))
                      print("newGetfirmwareVersionData success")
                  }
              }
          }
          
02bd7bf8   jason   feat:no disturb
767
768
769
770
771
772
773
774
775
776
777
          let archiveAction106 = UIAlertAction(title: "newGetNoDisturbData", style: .default) {[weak self] action in
              BluetoothManager.shared.newGetNoDisturbData() {noDisturb, error in
                  if error != nil {
                      print("newGetNoDisturbData" + (error?.description ?? ""))
                  }else {
                      self?.showDetailAlert(msg: noDisturb?.description)
                      print("newGetNoDisturbData success")
                  }
              }
          }
          
728a0182   jason   feat:wrist sense
778
779
780
781
782
783
784
785
786
787
788
          let archiveAction107 = UIAlertAction(title: "newGetWristSenseData", style: .default) {[weak self] action in
              BluetoothManager.shared.newGetWristSenseData() {enable, error in
                  if error != nil {
                      print("newGetWristSenseData" + (error?.description ?? ""))
                  }else {
                      self?.showDetailAlert(msg: String(enable))
                      print("newGetWristSenseData success")
                  }
              }
          }
          
6adf1dc1   jason   feat:bo auto detect
789
790
791
792
793
794
795
796
797
798
799
          let archiveAction108 = UIAlertAction(title: "newGetBoAutoDetectData", style: .default) {[weak self] action in
              BluetoothManager.shared.newGetBoAutoDetectData() {enable, error in
                  if error != nil {
                      print("newGetBoAutoDetectData" + (error?.description ?? ""))
                  }else {
                      self?.showDetailAlert(msg: String(enable))
                      print("newGetBoAutoDetectData success")
                  }
              }
          }
          
b74ad0a2   jason   feat:bo remind & ...
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
          let archiveAction109 = UIAlertAction(title: "newGetBoLowRemindData", style: .default) {[weak self] action in
              BluetoothManager.shared.newGetBoLowRemindData() {value, error in
                  if error != nil {
                      print("newGetBoLowRemindData" + (error?.description ?? ""))
                  }else {
                      self?.showDetailAlert(msg: String(value))
                      print("newGetBoLowRemindData success")
                  }
              }
          }
          
          let archiveAction110 = UIAlertAction(title: "newGetHrAutoDetectData", style: .default) {[weak self] action in
              BluetoothManager.shared.newGetHrAutoDetectData() {enable, error in
                  if error != nil {
                      print("newGetHrAutoDetectData" + (error?.description ?? ""))
                  }else {
                      self?.showDetailAlert(msg: String(enable))
                      print("newGetHrAutoDetectData success")
                  }
              }
          }
          
4239cb3b   jason   feat:exercise hr ...
822
823
824
825
826
827
828
829
830
831
832
          let archiveAction111 = UIAlertAction(title: "newGetExerciseHrRemindData", style: .default) {[weak self] action in
              BluetoothManager.shared.newGetExerciseHrRemindData() {enable, error in
                  if error != nil {
                      print("newGetExerciseHrRemindData" + (error?.description ?? ""))
                  }else {
                      self?.showDetailAlert(msg: String(enable))
                      print("newGetExerciseHrRemindData success")
                  }
              }
          }
          
40bc8724   jason   feat:firmware ver...
833
          
a833b1ce   jason   feat:sleep now & ...
834
835
          alert.addAction(archiveAction9a)
          alert.addAction(archiveAction9b)
737bea72   jason   feat:blood oxygen...
836
837
          alert.addAction(archiveAction10a)
          alert.addAction(archiveAction10b)
191ca3ba   jason   feat:heart rate n...
838
839
          alert.addAction(archiveAction14a)
          alert.addAction(archiveAction14b)
6e1c7072   jason   feat:step now & h...
840
841
          alert.addAction(archiveAction15a)
          alert.addAction(archiveAction15b)
6e1c7072   jason   feat:step now & h...
842
843
          alert.addAction(archiveAction17a)
          alert.addAction(archiveAction17b)
66e40f13   jason   feat: blood oxyge...
844
          alert.addAction(archiveAction22)
6e0a8d81   jason   feat:gps now & hi...
845
846
          alert.addAction(archiveAction101a)
          alert.addAction(archiveAction101b)
36b76cd7   jason   feat:intensive ti...
847
848
          alert.addAction(archiveAction102a)
          alert.addAction(archiveAction102b)
6a02f533   jason   feat:beidou card
849
          alert.addAction(archiveAction103)
b867ff0e   jason   feat:fetch exerci...
850
851
          alert.addAction(archiveAction104a)
          alert.addAction(archiveAction104b)
40bc8724   jason   feat:firmware ver...
852
          alert.addAction(archiveAction105)
02bd7bf8   jason   feat:no disturb
853
          alert.addAction(archiveAction106)
728a0182   jason   feat:wrist sense
854
          alert.addAction(archiveAction107)
6adf1dc1   jason   feat:bo auto detect
855
          alert.addAction(archiveAction108)
b74ad0a2   jason   feat:bo remind & ...
856
857
          alert.addAction(archiveAction109)
          alert.addAction(archiveAction110)
4239cb3b   jason   feat:exercise hr ...
858
          alert.addAction(archiveAction111)
66e40f13   jason   feat: blood oxyge...
859
860
861
862
863
          
          alert.addAction(UIAlertAction(title: "取消", style: .destructive, handler: nil))
          present(alert, animated: true, completion: nil)
      }
      
cdaa3f52   jason   feat:log alert
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
      func showDetailAlert(msg: String? = "") {
          let alert = UIAlertController(title: "info", message: msg, preferredStyle: .alert)
  //        let archiveAction = UIAlertAction(title: "newGetGpsData", style: .default) { action in
  //            BluetoothManager.shared.newGetGpsData() {gpsModel, error in
  //                if error != nil {
  //                    print("newGetGpsData" + (error?.description ?? ""))
  //                }else {
  //                    print("newGetGpsData success")
  //                }
  //            }
  //        }
  //        alert.addAction(archiveAction)
          
          alert.addAction(UIAlertAction(title: "确定", style: .destructive, handler: nil))
          present(alert, animated: true, completion: nil)
      }
f2cf74c7   yangbin   1.0.20(4)
880
  }
0f975482   jason   feat:exercise
881
882
883
884
885
886
887
888
889
  
  extension MineViewController: BluetoothSyncDelegate {
      func didReceiveExerciseStatus(value: Int) {
          showDetailAlert(msg: "ExerciseStatus is " + String(value))
      }
      
      func didReceiveExerciseRealtimeData(realtimeData: NewExerciseRealtimeModel) {
          showDetailAlert(msg: realtimeData.description)
      }
b867ff0e   jason   feat:fetch exerci...
890
891
892
893
      
      func didReceiveExerciseData(exerciseData: NewExerciseModel) {
          showDetailAlert(msg: exerciseData.description)
      }
0f975482   jason   feat:exercise
894
  }