util.js 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. function formatTime(date) {
  2. var year = date.getFullYear()
  3. var month = date.getMonth() + 1
  4. var day = date.getDate()
  5. var hour = date.getHours()
  6. var minute = date.getMinutes()
  7. var second = date.getSeconds()
  8. return [year, month, day].map(formatNumber).join('-') + ' ' + [hour, minute, second].map(formatNumber).join(':')
  9. }
  10. function formatNumber(n) {
  11. n = n.toString()
  12. return n[1] ? n : '0' + n
  13. }
  14. function changeCup(e) {
  15. // e== 1正面,2背面,3手柄,4杯底
  16. let dataPositionObj = null, propSize = null;
  17. switch (e) {
  18. case '1':
  19. // console.log('正面')
  20. dataPositionObj = { // 正面数据
  21. top: 42,
  22. left: 256,
  23. width: 334,
  24. height: 450
  25. };
  26. propSize = {
  27. top: '6cm',
  28. right: '9.5cm',
  29. bottom: '6cm',
  30. left: '9.5cm',
  31. };
  32. break;
  33. case '2':
  34. dataPositionObj = { // 侧面数据
  35. top: 42,
  36. left: 154,
  37. width: 334,
  38. height: 450
  39. };
  40. propSize = {
  41. top: '6cm',
  42. right: '9.5cm',
  43. bottom: '6cm',
  44. left: '9.5cm',
  45. };
  46. // console.log('背面');
  47. break;
  48. case '3':
  49. dataPositionObj = { // 手柄数据
  50. top: 172,
  51. left: 346,
  52. width: 70,
  53. height: 246
  54. };
  55. propSize = {
  56. top: '1cm',
  57. right: '5cm',
  58. bottom: '1cm',
  59. left: '5cm',
  60. };
  61. // console.log('手柄');
  62. break;
  63. case '4':
  64. dataPositionObj = { // 正面数据
  65. top: 138,
  66. left: 178,
  67. width: 304,
  68. height: 304
  69. };
  70. propSize = {
  71. top: '5cm',
  72. right: '5cm',
  73. bottom: '5cm',
  74. left: '5cm',
  75. };
  76. // console.log('杯底');
  77. break;
  78. case '5': //表示是箱子
  79. dataPositionObj = { // 正面数据
  80. top: 74,
  81. left: 104,
  82. width: 536,
  83. height: 712
  84. };
  85. propSize = {
  86. top: '',
  87. right: '',
  88. bottom: '',
  89. left: '',
  90. };
  91. // console.log('杯底');
  92. break;
  93. case '6': //表示是箱子
  94. dataPositionObj = { // 正面数据
  95. top: 128,
  96. left: 109,
  97. width: 534,
  98. height: 654
  99. };
  100. propSize = {
  101. top: '',
  102. right: '',
  103. bottom: '',
  104. left: '',
  105. };
  106. break;
  107. case '7': //表示是箱子
  108. dataPositionObj = { // 正面数据
  109. top: 74,
  110. left: 104,
  111. width: 536,
  112. height: 712
  113. };
  114. propSize = {
  115. top: '',
  116. right: '',
  117. bottom: '',
  118. left: '',
  119. };
  120. // console.log('杯底');
  121. break;
  122. case '8': //表示是箱子
  123. dataPositionObj = { // 正面数据
  124. top: 128,
  125. left: 109,
  126. width: 534,
  127. height: 654
  128. };
  129. propSize = {
  130. top: '',
  131. right: '',
  132. bottom: '',
  133. left: '',
  134. };
  135. break;
  136. case '9': //黑色T恤
  137. dataPositionObj = {
  138. top: 254,
  139. left: 204,
  140. width: 368,
  141. height: 440
  142. };
  143. propSize = {
  144. top: '',
  145. right: '',
  146. bottom: '',
  147. left: '',
  148. };
  149. break;
  150. case '10': //红色T恤
  151. dataPositionObj = {
  152. top: 254,
  153. left: 204,
  154. width: 368,
  155. height: 440
  156. };
  157. propSize = {
  158. top: '',
  159. right: '',
  160. bottom: '',
  161. left: '',
  162. };
  163. break;
  164. case '11': //白色杯子
  165. dataPositionObj = {
  166. top: 320,
  167. left: 264,
  168. width: 228,
  169. height: 456
  170. };
  171. propSize = {
  172. top: '',
  173. right: '',
  174. bottom: '',
  175. left: '',
  176. };
  177. break;
  178. case '12': //黑色杯子
  179. dataPositionObj = {
  180. top: 244,
  181. left: 260,
  182. width: 228,
  183. height: 522
  184. };
  185. propSize = {
  186. top: '',
  187. right: '',
  188. bottom: '',
  189. left: '',
  190. };
  191. break;
  192. default:
  193. break;
  194. }
  195. return {
  196. dataPositionObj: dataPositionObj,
  197. propSize: propSize
  198. }
  199. }
  200. let url = 'https://dlz.info666.com';
  201. let changeImg={
  202. '5': url+'/temp/box_silvery1.png',//银色箱子正面
  203. '5_1': url +'/temp/box_silvery1_1.png', //银色箱子正面镂空
  204. '5_2': url +'/temp/box_silvery1_2.png', //银色箱子正面
  205. '6': url +'/temp/box_silvery2.png',//银色箱子反面
  206. '6_1': url +'/temp/box_silvery2_1.png', //银色箱子镂空
  207. '6_2': url +'/temp/box_silvery2_2.png', //银色箱子
  208. '7': url +'/temp/box_white1.png',//白色箱子正面
  209. '7_1': url +'/temp/box_white1_1.png', //白色箱子正面有颜色镂空
  210. '7_2': url +'/temp/box_white1_2.png', //白色箱子正面镂空无颜色
  211. '8': url +'/temp/box_white2.png',//白色箱子反面
  212. '8_1': url +'/temp/box_white2_1.png', //白色箱子镂空
  213. '8_2': url +'/temp/box_white2_2.png', //白色箱子镂空无颜色
  214. '9': url +'/temp/shirt1.png',//黑色T恤
  215. '9_1': url +'/temp/shirt1_1.png', //黑色T恤镂空
  216. '9_2': url +'/temp/shirt1_2.png', //黑色T恤
  217. '10': url +'/temp/shirt2.png',//红色T恤
  218. '10_1': url +'//temp/shirt2_1.png',//红色T恤镂空
  219. '10_2': url +'/temp/shirt2_2.png',//红色T恤
  220. '11': url +'/temp/cup1.png',//白色杯子
  221. '11_1': url +'/temp/cup1_1.png',//白色杯子镂空
  222. '11_2': url +'/temp/cup1_2.png',//白色杯子
  223. '12': url +'/temp/cup2.png',//黑色杯子
  224. '12_1': url +'/temp/cup2_1.png',//黑色杯子镂空
  225. '12_2': url +'/temp/cup2_2.png',//黑色杯子
  226. }
  227. module.exports = {
  228. formatTime: formatTime,
  229. changeCup: changeCup,
  230. changeImg: changeImg
  231. }
  232. // function imageUtil(e) {
  233. // var imageSize = {};
  234. // var originalWidth = e.detail.width;//图片原始宽
  235. // var originalHeight = e.detail.height;//图片原始高
  236. // var originalScale = originalHeight / originalWidth;//图片高宽比
  237. // //获取屏幕宽高
  238. // wx.getSystemInfo({
  239. // success: function (res) {
  240. // var windowWidth = res.windowWidth;
  241. // var windowHeight = res.windowHeight;
  242. // var windowscale = windowHeight / windowWidth;//屏幕高宽比
  243. // imageSize.imageHeight = (windowWidth * originalHeight) / originalWidth;
  244. // }
  245. // })
  246. // //return imageSize;
  247. // }
  248. // module.exports = {
  249. // imageUtil: imageUtil
  250. // }
  251. // import _Promise from 'bluebird';
  252. // /**
  253. // * @param {Function} fun 接口
  254. // * @param {Object} options 接口参数
  255. // * @returns {Promise} Promise对象
  256. // */
  257. // function Promise(fun, options) {
  258. // options = options || {};
  259. // return new _Promise((resolve, reject) => {
  260. // if (typeof fun !== 'function') {
  261. // reject();
  262. // }
  263. // options.success = resolve;
  264. // options.fail = reject;
  265. // fun(options);
  266. // });
  267. // }
  268. // /**
  269. // * 手势库
  270. // */
  271. // function touchstart(e, _this) {
  272. // const t = e.touches[0],
  273. // startX = t.clientX,
  274. // startY = t.clientY;
  275. // _this.setData({
  276. // 'gesture.startX': startX,
  277. // 'gesture.startY': startY,
  278. // 'gesture.out': true
  279. // })
  280. // }
  281. // /**
  282. // * 左滑
  283. // * @returns {boolean} 布尔值
  284. // */
  285. // function isLeftSlide(e, _this) {
  286. // if (_this.data.gesture.out) {
  287. // const t = e.touches[0],
  288. // deltaX = t.clientX - _this.data.gesture.startX,
  289. // deltaY = t.clientY - _this.data.gesture.startY;
  290. // if (deltaX < -20 && deltaX > -40 && deltaY < 8 && deltaY > -8) {
  291. // _this.setData({
  292. // 'gesture.out': false
  293. // })
  294. // return true;
  295. // } else {
  296. // return false;
  297. // }
  298. // }
  299. // }
  300. // /**
  301. // * 右滑
  302. // * @returns {boolean} 布尔值
  303. // */
  304. // function isRightSlide(e, _this) {
  305. // if (_this.data.gesture.out) {
  306. // const t = e.touches[0],
  307. // deltaX = t.clientX - _this.data.gesture.startX,
  308. // deltaY = t.clientY - _this.data.gesture.startY;
  309. // if (deltaX > 20 && deltaX < 40 && deltaY < 8 && deltaY > -8) {
  310. // _this.setData({
  311. // 'gesture.out': false
  312. // })
  313. // return true;
  314. // } else {
  315. // return false;
  316. // }
  317. // }
  318. // }
  319. // module.exports = {
  320. // Promise: Promise,
  321. // Gesture: {
  322. // touchstart: touchstart,
  323. // isLeftSlide: isLeftSlide,
  324. // isRightSlide: isRightSlide
  325. // }
  326. // }