PageRenderTime 26ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/src/gaoqi-py/static/js/module/activity-container/activity-containers.js

https://bitbucket.org/bobyuxinyang/letsgaoqi
JavaScript | 281 lines | 149 code | 12 blank | 120 comment | 3 complexity | 35714f25b1c4597115d83baa332010eb MD5 | raw file
  1. /**
  2. * Created by PyCharm.
  3. * User: meteor1211
  4. * Date: 11-11-24
  5. * Time: 下午3:40
  6. * To change this template use File | Settings | File Templates.
  7. */
  8. define(function (require) {
  9. var service = require('utility/service');
  10. require('module/activity-container/activity-container');
  11. window.AcitivityContainerList = Backbone.Collection.extend({
  12. model: ActivityContainer,
  13. comparator: function (e) {
  14. },
  15. initialize: function (model, status) {
  16. status == 'mine' ? this.getMine() : this.getFrirends();
  17. },
  18. getMine: function () {
  19. //todo:获得我 求得活动 以及 我参加的活动
  20. // var mine = {
  21. // user:{
  22. // "username": "\u6768\u946b\u8bdaBruce",
  23. //// "_id": "4ecc6973a2da1e0ba4000001",
  24. // "_id": "4ecce89e15ab44032c000001",
  25. // "profile_image_url": "http://tp1.sinaimg.cn/1862940640/50/5613480639/1"
  26. // },
  27. // activity_list: [{
  28. // 'activity_id': 1,
  29. // 'created_at': new Date().toEpoch() - 30000,
  30. // 'text': '哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇哇',
  31. // 'plan_at': new Date().toEpoch() + 30000,
  32. // 'participators':[{
  33. // 'update_at': new Date().toEpoch() - 70000,
  34. // 'user': {
  35. // '_id': 11, 'username': '王昊', 'description': 1, 'profile_image_url': 'http://tp3.sinaimg.cn/1930080130/50/5609852091/0', 'weibo_id': '1930080130'
  36. // }
  37. // },
  38. // {
  39. // 'update_at': new Date().toEpoch() - 60000,
  40. // 'user': {
  41. // '_id': 11, 'username': '王昊', 'description': 1, 'profile_image_url': 'http://tp2.sinaimg.cn/1310915297/50/5614164220/0', 'weibo_id': '1310915297'
  42. // }
  43. // }],
  44. // tags: [{
  45. // 'order': 2, 'name': '逛公园'
  46. // }, {
  47. // 'order': 3, 'name': '听讲座'
  48. // }],
  49. // 'comment_count': '3'
  50. // },
  51. // {
  52. // 'activity_id': 1,
  53. // 'created_at': new Date().toEpoch() - 80000,
  54. // 'text': '哼哼哼哼哼哼哼哼哼哼哼哼哼哼哼哼哼哼哼哼哼哼哼',
  55. // 'plan_at': new Date().toEpoch() + 30000,
  56. // 'participators':[{
  57. // 'update_at': new Date().toEpoch() - 20000,
  58. // 'user': {
  59. // '_id': 11, 'username': '王昊', 'description': 1, 'profile_image_url': 'http://tp3.sinaimg.cn/1930080130/50/5609852091/0', 'weibo_id': '1930080130'
  60. // }
  61. // },
  62. // {
  63. // 'update_at': new Date().toEpoch() - 40000,
  64. // 'user': {
  65. // '_id': 99, 'username': '王昊', 'description': 1, 'profile_image_url': 'http://tp2.sinaimg.cn/1310915297/50/5614164220/0', 'weibo_id': '1310915297'
  66. // }
  67. // }],
  68. // tags: [{
  69. // 'order': 2, 'name': '梦游'
  70. // }, {
  71. // 'order': 3, 'name': '踢足球'
  72. // },{
  73. // 'order': 4, 'name': '摄影'
  74. // }],
  75. // 'comment_count': '5'
  76. // }],
  77. // requested_list: [{
  78. // 'activity_id': 1,
  79. // 'created_at': new Date().toEpoch() - 3000,
  80. // 'text': '啊啊啊啊啊啊啊啊啊',
  81. // 'plan_at': new Date().toEpoch() + 3000,
  82. // 'participators':[{
  83. // 'update_at': new Date().toEpoch() - 2000,
  84. // 'user': {
  85. // '_id': '4ecce89e15ab44032c000001', 'username': '陈陈', 'description': 1, 'profile_image_url': 'http://tp1.sinaimg.cn/1862940640/50/5613480639/1', 'weibo_id': '1930080130'
  86. // }
  87. // },
  88. // {
  89. // 'update_at': new Date().toEpoch() - 4000,
  90. // 'user': {
  91. // '_id': '4ecce89e15ab44032c000005', 'username': '黄光', 'description': 1, 'profile_image_url': 'http://tp2.sinaimg.cn/1310915297/50/5614164220/0', 'weibo_id': '1310915297'
  92. // }
  93. // }],
  94. // tags: [{
  95. // 'order': 2, 'name': '逛街'
  96. // }, {
  97. // 'order': 3, 'name': '吃饭'
  98. // },{
  99. // 'order': 4, 'name': '看电影'
  100. // }]
  101. //
  102. // },
  103. // {
  104. // 'activity_id': 1,
  105. // 'created_at': new Date().toEpoch() - 8000,
  106. // 'text': '呀呀呀哎呀呀呀呀',
  107. // 'plan_at': new Date().toEpoch() + 3000,
  108. // 'participators':[{
  109. // 'update_at': new Date().toEpoch() - 2000,
  110. // 'user': {
  111. // '_id': '4ecce89e15ab44032c000001', 'username': 'meizi', 'description': 1, 'profile_image_url': 'http://tp1.sinaimg.cn/1862940640/50/5613480639/1', 'weibo_id': '1930080130'
  112. // }
  113. // },
  114. // {
  115. // 'update_at': new Date().toEpoch() - 4000,
  116. // 'user': {
  117. // '_id': 66, 'username': '妹纸', 'description': 1, 'profile_image_url': 'http://tp2.sinaimg.cn/1310915297/50/5614164220/0', 'weibo_id': '1310915297'
  118. // }
  119. // }],
  120. // tags: [{
  121. // 'order': 2, 'name': '骑车'
  122. // }, {
  123. // 'order': 3, 'name': '徒步'
  124. // },{
  125. // 'order': 4, 'name': '随便逛逛'
  126. // }]
  127. //
  128. // }]
  129. // };
  130. var mine = {
  131. user:{
  132. "username": "\u6768\u946b\u8bdaBruce",
  133. "_id": window.Current_user['_id'],
  134. "profile_image_url": "http://tp1.sinaimg.cn/1862940640/50/5613480639/1"
  135. },
  136. activity_list: [],
  137. requested_list:[]
  138. }
  139. //将自己感兴趣的和参加的活动Json 转成 Array
  140. if(mine instanceof Object && !mine instanceof Array)
  141. mine = [mine];
  142. this.add(mine);
  143. this.trigger('getMine');
  144. },
  145. getFrirends: function () {
  146. //todo:获得我朋友们 求得活动 以及 我参加的活动
  147. var friends = [{
  148. user:{
  149. "username": "迪susan",
  150. "_id": "4ecc6973a2da1e0ba4000003",
  151. "profile_image_url": "http://tp2.sinaimg.cn/1890984777/50/5604155970/01"
  152. },
  153. activity_list: [{
  154. 'activity_id': 1,
  155. 'created_at': new Date().toEpoch() - 80000,
  156. 'text': '咦咦咦咦咦咦咦咦咦咦咦咦',
  157. 'plan_at': new Date().toEpoch() + 30000,
  158. 'participators':[{
  159. 'update_at': new Date().toEpoch() - 20000,
  160. 'user': {
  161. '_id': window.Current_user['_id'], 'username': '王昊', 'description': 1, 'profile_image_url': 'http://tp3.sinaimg.cn/1930080130/50/5609852091/0', 'weibo_id': '1930080130'
  162. }
  163. },
  164. {
  165. 'update_at': new Date().toEpoch() - 40000,
  166. 'user': {
  167. '_id': 11, 'username': '王昊', 'description': 1, 'profile_image_url': 'http://tp2.sinaimg.cn/1310915297/50/5614164220/0', 'weibo_id': '1310915297'
  168. }
  169. }],
  170. tags: [{
  171. 'order': 2, 'name': '梦游'
  172. }, {
  173. 'order': 3, 'name': '踢足球'
  174. },{
  175. 'order': 4, 'name': '摄影'
  176. }],
  177. 'comment_count': '5'
  178. }],
  179. requested_list: [{
  180. 'activity_id': 1,
  181. 'created_at': new Date().toEpoch() - 8000,
  182. 'text': '咔咔咔咔咔咔咔咔咔',
  183. 'plan_at': new Date().toEpoch() + 3000,
  184. 'participators':[{
  185. 'update_at': new Date().toEpoch() - 2000,
  186. 'user': {
  187. '_id': window.Current_user['_id'], 'username': '王昊', 'description': 1, 'profile_image_url': 'http://tp3.sinaimg.cn/1930080130/50/5609852091/0', 'weibo_id': '1930080130'
  188. }
  189. },
  190. {
  191. 'update_at': new Date().toEpoch() - 4000,
  192. 'user': {
  193. '_id': 55, 'username': '王昊', 'description': 1, 'profile_image_url': 'http://tp2.sinaimg.cn/1310915297/50/5614164220/0', 'weibo_id': '1310915297'
  194. }
  195. }],
  196. tags: [{
  197. 'order': 2, 'name': '骑车'
  198. }, {
  199. 'order': 3, 'name': '徒步'
  200. },{
  201. 'order': 4, 'name': '随便逛逛'
  202. }]
  203. }]
  204. },
  205. {
  206. user:{
  207. "username": "Cherry_if茹",
  208. "_id": "4ecc6973a2da1e0ba4000002",
  209. "profile_image_url": "http://tp2.sinaimg.cn/1979743057/50/5608384915/0"
  210. },
  211. activity_list: [{
  212. 'activity_id': 1,
  213. 'created_at': new Date().toEpoch() - 80000,
  214. 'text': '呢呢呢呢呢呢呢呢',
  215. 'plan_at': new Date().toEpoch() + 30000,
  216. 'participators':[{
  217. 'update_at': new Date().toEpoch() - 20000,
  218. 'user': {
  219. '_id': 33, 'username': '王昊', 'description': 1, 'profile_image_url': 'http://tp3.sinaimg.cn/1930080130/50/5609852091/0', 'weibo_id': '1930080130'
  220. }
  221. }],
  222. tags: [{
  223. 'order': 2, 'name': '梦游'
  224. }, {
  225. 'order': 3, 'name': '踢足球'
  226. },{
  227. 'order': 4, 'name': '摄影'
  228. }],
  229. 'comment_count': '5'
  230. }],
  231. requested_list: []
  232. },{
  233. user:{
  234. "username": "Cherry_if茹",
  235. "_id": "4ecc6973a2da1e0ba4000002",
  236. "profile_image_url": "http://tp2.sinaimg.cn/1979743057/50/5608384915/0"
  237. },
  238. activity_list: [],
  239. requested_list: [{
  240. 'activity_id': 1,
  241. 'created_at': new Date().toEpoch() - 8000,
  242. 'text': '咔咔咔咔咔咔咔咔咔',
  243. 'plan_at': new Date().toEpoch() + 3000,
  244. 'participators':[{
  245. 'update_at': new Date().toEpoch() - 2000,
  246. 'user': {
  247. '_id': 44, 'username': '王昊', 'description': 1, 'profile_image_url': 'http://tp3.sinaimg.cn/1930080130/50/5609852091/0', 'weibo_id': '1930080130'
  248. }
  249. },
  250. {
  251. 'update_at': new Date().toEpoch() - 4000,
  252. 'user': {
  253. '_id': 55, 'username': '王昊', 'description': 1, 'profile_image_url': 'http://tp2.sinaimg.cn/1310915297/50/5614164220/0', 'weibo_id': '1310915297'
  254. }
  255. }],
  256. tags: [{
  257. 'order': 2, 'name': '骑车'
  258. }, {
  259. 'order': 3, 'name': '徒步'
  260. },{
  261. 'order': 4, 'name': '随便逛逛'
  262. }]
  263. }]
  264. }];
  265. this.add(friends);
  266. this.trigger('getFrirends');
  267. }
  268. });
  269. });