viewcase.js 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. // index/pages/viewcase/viewcase.js
  2. const app = getApp();
  3. var utils = require("../../../utils/http");
  4. var designTimer = null;
  5. var time = 0;
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. cid: '',
  12. dscDataMsg: '',
  13. detail: {},
  14. companyobj: {},
  15. loginFlag: false,
  16. canIUseGetUserProfile: false,
  17. designPlan: false,
  18. phoneFlag:false,
  19. type:'',//1就是分享进来的
  20. top: app.globalData.statusBarHeight,
  21. hgt: app.globalData.titleBarHeight,
  22. employeeflag: false,//false是用户,true是员工
  23. },
  24. /**
  25. * 生命周期函数--监听页面加载
  26. */
  27. onLoad(options) {
  28. if (wx.getUserProfile) {
  29. this.setData({
  30. canIUseGetUserProfile: true
  31. })
  32. }
  33. this.setData({
  34. type:''
  35. })
  36. if (!!options.cid) {
  37. this.setData({
  38. cid: options.cid
  39. })
  40. if (options.type == 1) {
  41. this.devCaseDetail();
  42. } else {
  43. this.setData({
  44. type:1
  45. })
  46. if (!!options.ctp) {
  47. app.globalData.clientype = options.ctp;
  48. }
  49. if (!!options.uid) {
  50. app.globalData.shareuserid = options.uid;
  51. }
  52. this.login();
  53. }
  54. }
  55. wx.hideHomeButton();
  56. },
  57. login: function () {
  58. var that = this;
  59. wx.login({
  60. success: function (data) {
  61. if (data.errMsg == 'login:ok') {
  62. utils.$post({
  63. url: app.globalData.webUrl + 'api/users/code2sessionmini',
  64. data: {
  65. code: data.code,
  66. share: app.globalData.shareuserid,
  67. client_type:app.globalData.clientype
  68. },
  69. success: function (r) {
  70. if (r.data.code == '0') {
  71. app.globalData.sharepersonobj = r.data.share;
  72. app.globalData.token = r.data.token;
  73. app.globalData.companyobj=r.data.company_data;
  74. that.sharecompany();
  75. that.setData({
  76. sharepersonMsg: app.globalData.sharepersonobj,
  77. })
  78. app.globalData.personMsg = r.data.user;
  79. app.globalData.companyname=r.data.company;
  80. app.globalData.official_openid = r.data.official_openid;
  81. app.globalData.agentEmployeEid = r.data.agent_employee_id;
  82. if (!!r.data.user.phone) {
  83. that.setData({
  84. employeeflag: (!!r.data.user.binded && r.data.user.binded.state == '在职') ? true : false
  85. })
  86. app.globalData.personMsg = r.data.user;
  87. app.globalData.use_id = r.data.user.id;
  88. if (!!r.data.user.binded && r.data.user.binded.state == '在职'){
  89. app.globalData.currentUserId = r.data.user.binded.id;
  90. }
  91. app.globalData.phone = true;//有手机号
  92. that.setData({
  93. phoneFlag: false,
  94. })
  95. var obj = {
  96. detail: 1
  97. }
  98. that.devClientCaseDetail(obj);
  99. } else {
  100. wx.hideLoading();
  101. that.setData({
  102. loginFlag: false,
  103. phoneFlag: true
  104. })
  105. }
  106. } else {
  107. setTimeout(function () {
  108. wx.hideLoading()
  109. }, 500)
  110. }
  111. }
  112. })
  113. }
  114. }
  115. })
  116. },
  117. sharecompany:function (){
  118. const that=this;
  119. utils.$post({
  120. url: app.globalData.webUrl + 'client/index/content_belong_company',
  121. header: {
  122. 'Authorization':'bearer '+app.globalData.token
  123. },
  124. data:{
  125. client_type:app.globalData.clientype,
  126. uid: app.globalData.shareuserid
  127. },
  128. success: function (res) {
  129. if(res.data.code=='0'){
  130. app.globalData.currentUserId = res.data.data.employee_id;
  131. that.setData({
  132. companyobj:res.data.data
  133. })
  134. }
  135. },
  136. complete(res) {
  137. wx.hideLoading()
  138. }
  139. })
  140. },
  141. golastap(){
  142. wx.navigateBack()
  143. },
  144. devCaseDetail() {
  145. var that = this;
  146. utils.$get({
  147. url: app.globalData.webUrl + 'api/building/dev_case_detail',
  148. header: {
  149. 'Authorization': 'bearer ' + app.globalData.token
  150. },
  151. data: {
  152. id: that.data.cid,
  153. },
  154. success: function (res) {
  155. if (res.data.code == '0') {
  156. wx.setNavigationBarTitle({
  157. title: res.data.data.name,
  158. })
  159. that.setData({
  160. dscDataMsg: res.data.data.content,
  161. detail: res.data.data
  162. })
  163. } else {
  164. wx.showToast({
  165. title: res.data.msg,
  166. icon: 'none',
  167. duration: 1500
  168. })
  169. }
  170. }
  171. })
  172. },
  173. devClientCaseDetail() {
  174. var that = this;
  175. utils.$get({
  176. url: app.globalData.webUrl + 'client/building/dev_case_detail',
  177. header: {
  178. 'Authorization': 'bearer ' + app.globalData.token
  179. },
  180. data: {
  181. id: that.data.cid,
  182. },
  183. success: function (res) {
  184. if (res.data.code == '0') {
  185. wx.setNavigationBarTitle({
  186. title: res.data.data.name,
  187. })
  188. that.setData({
  189. dscDataMsg: res.data.data.content,
  190. detail: res.data.data
  191. })
  192. } else {
  193. wx.showToast({
  194. title: res.data.msg,
  195. icon: 'none',
  196. duration: 1500
  197. })
  198. }
  199. }
  200. })
  201. },
  202. closeDesigntap(e) {
  203. if (designTimer) {
  204. clearTimeout(designTimer);
  205. }
  206. if (e.detail.type == 'success') {
  207. this.setData({
  208. designPlan: false
  209. })
  210. } else {
  211. this.setData({
  212. designPlan: false
  213. })
  214. }
  215. },
  216. visitimefun() {
  217. const that = this;
  218. utils.$post({
  219. url: app.globalData.webUrl + 'client/index/visit_due_time',
  220. header: {
  221. 'Authorization': 'bearer ' + app.globalData.token
  222. },
  223. data: {
  224. id: that.data.cid,
  225. pipe_type: 'devcase',
  226. time: time,
  227. },
  228. success: function (res) {}
  229. })
  230. },
  231. /**
  232. * 生命周期函数--监听页面初次渲染完成
  233. */
  234. onReady() {
  235. },
  236. /**
  237. * 生命周期函数--监听页面显示
  238. */
  239. onShow() {
  240. time = 0;
  241. setInterval(() => {
  242. time++;
  243. },1000)
  244. },
  245. gotoindextap(){
  246. wx.reLaunch({
  247. url: '/pages/consoledesk/consoledesk',
  248. })
  249. },
  250. /**
  251. * 生命周期函数--监听页面隐藏
  252. */
  253. onHide() {
  254. this.visitimefun();
  255. },
  256. /**
  257. * 生命周期函数--监听页面卸载
  258. */
  259. onUnload() {
  260. this.visitimefun();
  261. },
  262. /**
  263. * 页面相关事件处理函数--监听用户下拉动作
  264. */
  265. onPullDownRefresh() {
  266. },
  267. /**
  268. * 页面上拉触底事件的处理函数
  269. */
  270. onReachBottom() {
  271. },
  272. /**
  273. * 用户点击右上角分享
  274. */
  275. onShareAppMessage() {
  276. var that = this;
  277. return {
  278. title: that.data.detail.name,
  279. path: '/index/pages/viewcase/viewcase?cid=' + that.data.cid + '&uid=' + app.globalData.shareuserid + '&ctp=' + app.globalData.clientype + '&type=2'
  280. }
  281. }
  282. })