Personnel_details.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. // parents/pages/me/me.js
  2. import { routers, viewImage, sharePage, isFn, getGlobalVal } from '../../../utils/util.js'
  3. import { VipDetailInfo, EditVipservice } from '../../../utils/api.js'
  4. const { navigateTo, redirectTo, navigateBack } = routers()
  5. const { globalData, hasLibraryService, hasVipService, saveUserInfo, getWxloginCode} = getApp()
  6. const { baseImgUrl, qrcodeInvalidToastText } = globalData
  7. Page({
  8. /**
  9. * 页面的初始数据
  10. */
  11. data: {
  12. baseImgUrl,
  13. isLoaded: 0,
  14. isShowVipModal: 0,
  15. starttime: '',
  16. endTime:'',
  17. MembersVipId:"",
  18. callGetPhone: '',
  19. childId:'',
  20. canIUseGetUserInfo: wx.canIUse('button.open-type.getUserInfo'),
  21. routerOne: [
  22. {
  23. icon: '../../../assets/vip.png',
  24. text: '会员服务',
  25. time: '',
  26. paras: {},
  27. url: '',
  28. zindex: 3
  29. },
  30. ],
  31. routerTwo: [
  32. {
  33. icon: '../../../assets/personal_info.png',
  34. text: '个人信息',
  35. time: '',
  36. paras: {
  37. type: 1
  38. },
  39. url: 'president/pages/information/information',
  40. zindex: 3
  41. },
  42. {
  43. icon: '../../../assets/apply_pages.png',
  44. text: '借阅记录',
  45. time: '',
  46. paras: {},
  47. url: 'president/pages/management_loan_records/management_loan_records',
  48. zindex: 3
  49. },
  50. {
  51. icon: '../../../assets/problem_icon.png',
  52. text: '到馆记录',
  53. time: '',
  54. paras: {},
  55. url: 'president/pages/pavilion_record/pavilion_record',
  56. zindex: 3
  57. },
  58. ],
  59. footerData: {
  60. actIndex: 1,
  61. list: [
  62. {
  63. text: '日常事务',
  64. icon: '../../../assets/lock_gary.png',
  65. actIcon: '../../../assets/lock_blue.png',
  66. url: 'president/pages/home/home',
  67. zindex: 3,
  68. },
  69. {
  70. text: '人员管理',
  71. icon: '../../../assets/people_manager_gary.png',
  72. actIcon: '../../../assets/people_manager_blue.png',
  73. url: 'president/pages/Personnel_management/Personnel_management',
  74. zindex: 3,
  75. },
  76. {
  77. text: '我的',
  78. icon: '../../../assets/me_gray.png',
  79. actIcon: '../../../assets/me_blue.png',
  80. url: 'president/pages/me/me',
  81. zindex: 3,
  82. }
  83. ]
  84. }
  85. },
  86. /**
  87. * 生命周期函数--监听页面加载
  88. */
  89. onLoad: function (options) {
  90. // this.GetDate()
  91. this.setData({
  92. MembersVipId: options.vipId
  93. });
  94. wx.setStorageSync('vipId', options.vipId);
  95. options.vipId = getGlobalVal('vipId', `vipId_${getGlobalVal('userId')}`)
  96. options.libId = getGlobalVal('list').length > 0 ? getGlobalVal('list')[0].libId : ''
  97. wx.setNavigationBarTitle({
  98. title: `详情`,
  99. })
  100. this.setData(options)
  101. this.getvipInfoData(res => {
  102. this.setData({ isLoaded: 1 })
  103. })
  104. },
  105. /**
  106. * 生命周期函数--监听页面初次渲染完成
  107. */
  108. onReady: function () {
  109. const obj = { navigateTo, redirectTo, navigateBack, viewImage }
  110. for (const i in obj) {
  111. this[i] = obj[i]
  112. }
  113. },
  114. /**
  115. * 生命周期函数--监听页面显示
  116. */
  117. onShow: function () {
  118. },
  119. /**
  120. * 生命周期函数--监听页面隐藏
  121. */
  122. onHide: function () {
  123. },
  124. /**
  125. * 生命周期函数--监听页面卸载
  126. */
  127. onUnload: function () {
  128. },
  129. /**
  130. * 页面相关事件处理函数--监听用户下拉动作
  131. */
  132. onPullDownRefresh: function () {
  133. },
  134. /**
  135. * 页面上拉触底事件的处理函数
  136. */
  137. onReachBottom: function () {
  138. },
  139. /**
  140. * 用户点击右上角分享
  141. */
  142. onShareAppMessage: function () {
  143. if (isFn(sharePage)) return sharePage()
  144. },
  145. GetDate: function () {
  146. const now = new Date();
  147. const year = now.getFullYear();    //年
  148. const month = now.getMonth() + 1; //月
  149. const day = now.getDate();   //日
  150. const nowdate = year + '-' + month + '-' + day
  151. this.setData({ endTime: nowdate })
  152. },
  153. // 拨打电话给收件人
  154. callGetPhone(e) {
  155. // 号码
  156. let telPhone = e.currentTarget.dataset.getphone;
  157. this.callPhone(telPhone);
  158. },
  159. /**
  160. * 拨打电话 - 可简单封装工具集
  161. */
  162. callPhone(phoneNumber) {
  163. wx.makePhoneCall({
  164. phoneNumber: phoneNumber,
  165. success: function() {
  166. console.log("拨打电话成功!")
  167. },
  168. fail: function() {
  169. console.log("拨打电话失败!")
  170. }
  171. })
  172. },
  173. /**
  174. * 选择跳转进入页
  175. */
  176. selectRouteCtl: function (e) {
  177. const { index } = e.currentTarget.dataset
  178. const { routerTwo } = this.data
  179. const { url, zindex } = routerTwo[index]
  180. // if (index==2){
  181. navigateTo({ url, zindex })
  182. // }else{
  183. // if (!hasVipService()) return
  184. // navigateTo({ url, zindex })
  185. // }
  186. },
  187. /**
  188. * 提示框隐藏
  189. */
  190. allShowModel: function () {
  191. this.setData({ isShowVipModal: false })
  192. },
  193. /**
  194. * 会员管理详情
  195. */
  196. getvipInfoData: function (cb) {
  197. const continuousFn = { fn: this.getData, param: { ...arguments } }
  198. const { libId, month, MembersVipId } = this.data
  199. VipDetailInfo({ data: { libId, vipId: MembersVipId }, continuousFn }).then(res => {
  200. const { vipInfo } = res.data
  201. const { phone } = vipInfo
  202. this.setData({ vipInfo, callGetPhone: phone})
  203. console.log(vipInfo)
  204. if (isFn(cb)) cb()
  205. }).catch(res => {
  206. this.setData({ isLoaded: true })
  207. if (isFn(cb)) cb()
  208. })
  209. },
  210. /**
  211. * 显示修改会员服务有效期换框
  212. */
  213. toggleSelectVipCtl: function (e) {
  214. const { starttime, endtime, childid } = e.currentTarget.dataset
  215. this.setData({ isShowVipModal: !this.data.isShowVipModal, childId: childid,endTime: endtime, starttime: starttime })
  216. },
  217. /**
  218. * 修改会员服务有效期
  219. */
  220. submitCtl: function () {
  221. const continuousFn = { fn: this.submitCtl, param: { ...arguments } }
  222. const { libId, endTime, childId } = this.data
  223. EditVipservice({ data: { endTime, id: childId }, continuousFn }).then(res => {
  224. const { msg = [] } = res
  225. wx.showToast({
  226. title: msg ,
  227. icon: 'none'
  228. })
  229. })
  230. },
  231. /**
  232. * 选择日期
  233. */
  234. changeDate: function (e) {
  235. const { value } = e.detail;
  236. this.setData({ endTime: value })
  237. this.submitCtl(res => {
  238. this.setData({ isShowVipModal: false })
  239. })
  240. },
  241. /**
  242. * 获取微信用户信息
  243. */
  244. getUserInfoCtl: function (e) {
  245. const { detail } = e
  246. const { userInfo, errMsg = '触发获取微信用户信息失败' } = detail
  247. if (userInfo) {
  248. if (isFn(saveUserInfo)) saveUserInfo(detail, this.data.code)
  249. } else {
  250. wx.showToast({
  251. title: '触发微信授权失败',
  252. icon: 'none'
  253. })
  254. }
  255. }
  256. })