viewcase.js 9.1 KB

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